Beispiel #1
0
        public static System.Numerics.Vector3[] SpherePointCloud(float radius, System.Numerics.Vector3 center, int pointsNum)
        {
            var    data = new System.Numerics.Vector3[pointsNum];
            double x, yPos, y, zPos, z;

            for (int i = 0; i < pointsNum; i++)
            {
                x    = radius * (2 * RandomThreadStatic.NextDouble() - 1);
                yPos = Math.Sqrt(radius * radius - x * x);
                y    = yPos * (2 * RandomThreadStatic.NextDouble() - 1);
                zPos = Math.Sqrt(yPos * yPos - y * y);
                z    = RandomThreadStatic.Next(0, 2) == 0 ? -zPos : zPos;

                data[i] = new System.Numerics.Vector3((float)x, (float)y, (float)z) + center;
            }

            return(data);
        }
Beispiel #2
0
        private BezierCurve Repro(BezierCurve bezierCurve)
        {
            int     pointIndex = RandomThreadStatic.Next(1, _bezierControlPointsCount + 1);
            Vector3 direction  = RandomThreadStatic.NextPointCube(1);

            var bezierCurveRepro     = new BezierCurve(bezierCurve.Points);
            var bezierDirectionRepro = Vector3.Normalize(direction) * 1f * (float)RandomThreadStatic.NextDouble();

            bezierCurveRepro.Points[pointIndex] += bezierDirectionRepro;

            if (_manipulator.ApproxWithinReach(bezierCurveRepro.Points[pointIndex] + bezierDirectionRepro))
            {
                bezierCurveRepro.Points[pointIndex] += bezierDirectionRepro;
            }
            else
            {
                bezierCurveRepro.Points[pointIndex] -= bezierDirectionRepro;
            }

            return(bezierCurveRepro);
        }