Exemplo n.º 1
0
        /// <summary>
        /// Returns points in a defined spiral.
        /// </summary>
        /// <param name="origin">Center position of the spiral.</param>
        /// <param name="direction">Direction in which the spiral spans.</param>
        /// <param name="extent">Length of the spiral along the direction.</param>
        /// <param name="innerRadius">Inner radius of the spiral; the distance between the center and the first point of the spiral.</param>
        /// <param name="outerRadius">Outer radius of the spiral; the distance from the center to the last point of the spiral.</param>
        /// <param name="turns">Number of times the spiral turns in itself.</param>
        /// <param name="points">Number of points in the spiral.</param>
        /// <param name="rotation">Rotation of the spiral along the direction.</param>
        /// <returns></returns>
        public static List <Vector3> Spiral(Vector3 origin, Vector3 direction, float extent, float innerRadius, float outerRadius, int turns, int points, float rotation)
        {
            if (points <= 1 || innerRadius < 0)
            {
                return(null);
            }

            Vector3 circleNormal = direction - origin;

            Components.Plane plane = new Components.Plane(direction);

            float width              = (outerRadius - innerRadius) / (points - 1);
            float height             = extent / (points - 1);
            float angleBetweenPoints = turns * 360 / (points - 1);

            List <Vector3> spiral = new List <Vector3>();

            for (int i = 0; i < points; i++)
            {
                float separationAngle = rotation + i * angleBetweenPoints;

                Vector3 originDeviation = GetPoint(origin, origin + direction, height * i);

                Vector3 point = plane.GetPoint(originDeviation, innerRadius + width * i, separationAngle);
                spiral.Add(point);
            }

            return(spiral);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns points in a defined arc.
        /// </summary>
        /// <param name="origin">Center from which the arc is drawn.</param>
        /// <param name="normal">Normal vector of the arc; the direction in which it is pointing.</param>
        /// <param name="amplitude">Angle, in degrees, covered by the arc. 360 is a full circle.</param>
        /// <param name="horizontalRadius">Horizontal radius of an elliptic arc.</param>
        /// <param name="verticalRadius">Vertical radius of an elliptic arc.</param>
        /// <param name="radius">Radius of the arc; the distance between its center and a point.</param>
        /// <param name="points">Number of points in the arc.</param>
        /// <param name="rotation">Rotation of the circle; change the position of the first point.</param>
        /// <returns></returns>
        public static List <Vector3> Arc(Vector3 origin, Vector3 normal, float amplitude, float horizontalRadius, float verticalRadius, int points, float rotation)
        {
            if (horizontalRadius <= 0f || verticalRadius <= 0f)
            {
                return(null);
            }

            Vector3 arcNormal = normal - origin;

            Components.Plane plane = new Components.Plane(arcNormal);

            float amplitudeAngle = ClampAngle(amplitude);

            float angleBetweenPoints = 0f;

            if (amplitude < 360)
            {
                angleBetweenPoints = amplitude / (points - 1);
            }
            else
            {
                angleBetweenPoints = amplitude / points;
            }

            List <Vector3> circle = new List <Vector3>();

            for (int i = 0; i < points; i++)
            {
                float   separationAngle = rotation + i * angleBetweenPoints;
                Vector3 point           = plane.GetPoint(origin, horizontalRadius, verticalRadius, separationAngle);
                circle.Add(point);
            }

            return(circle);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Returns a point at given degrees and distance from origin around the normal of a geometrical plane.
 /// </summary>
 /// <param name="origin"></param>
 /// <param name="radius"></param>
 /// <param name="degrees"></param>
 /// <returns></returns>
 public static Vector3 GetPoint(Vector3 origin, Vector3 normal, float radius, float degrees)
 {
     Components.Plane plane = new Components.Plane(normal);
     return(plane.GetPoint(origin, radius, degrees));
 }