#region CPL License
/*
Nuclex Framework
Copyright (C) 2002-2009 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
IBM Common Public License for more details.
You should have received a copy of the IBM Common Public
License along with this library
*/
#endregion
using System;
using Microsoft.Xna.Framework;
namespace Nuclex.Geometry.Areas.PointGenerators {
/// Point generator for disc areas
public static class Disc3PointGenerator {
/// Returns a random point on the perimeter of a disc
/// Random number generator that will be used
/// Orientation of the disc in space
/// Radius of the disc
/// A random point on the disc's perimeter
public static Vector3 GenerateRandomPointOnPerimeter(
IRandom randomNumberGenerator, Matrix orientation, float radius
) {
// Use the 2D random point generator to get determine the random point
Vector2 point = Disc2PointGenerator.GenerateRandomPointOnPerimeter(
randomNumberGenerator, radius
);
// Transform the point by the disc's orientation matrix to get the world
// coordinates of the point
return Vector3.Transform(new Vector3(point.X, point.Y, 0.0f), orientation);
}
/// Returns a random point within a disc
/// Random number generator that will be used
/// Orientation of the disc in space
/// Radius of the disc
/// A random point within the disc
public static Vector3 GenerateRandomPointWithin(
IRandom randomNumberGenerator, Matrix orientation, float radius
) {
// Use the 2D random point generator to get determine the random point
Vector2 point = Disc2PointGenerator.GenerateRandomPointWithin(
randomNumberGenerator, radius
);
// Transform the point by the disc's orientation matrix to get the world
// coordinates of the point
return Vector3.Transform(new Vector3(point.X, point.Y, 0.0f), orientation);
}
}
} // namespace Nuclex.Geometry.Volumes.Generators