Пример #1
0
        private static IEnumerable <Line> CreateCylinderStartLines2(double alpha, int zLimit, int yLimit)
        {
            var b            = Sqrt(8) / 2;
            var alpha2       = 90 - alpha;
            var beta         = 180 - 45 - alpha2;
            var a            = 2 - Sin(alpha2.ToRadian()) / Sin(beta.ToRadian()) * b;
            var r            = CausticCylinder.R;
            var verticalLine = new Line((0, 0, -r), (-r, 0, 0));
            var distance     = Vector3D.AbsoluteValue(verticalLine.SecondPoint - verticalLine.BasePoint);
            var midpoint     = verticalLine.GetPointOnLine(distance / 2);

            var(xDir, yDir, zDir) = (-1, 0, -1 + a) - midpoint;

            var zRange = Numpy.LinSpace(0, distance, zLimit).ToList();
            var yRange = Numpy.LinSpace(0, CausticCylinder.L, yLimit).ToList();

            foreach (var z in zRange)
            {
                foreach (var y in yRange)
                {
                    var(x, y2, z2) = verticalLine.GetPointOnLine(z);
                    yield return(Line.FromPointAndDirection((x, y, z2), (xDir, yDir, zDir)));
                }
            }
        }
Пример #2
0
        private static IEnumerable <Line> OctoSphereStartOLD(double alpha, int xLimit, int yLimit)
        {
            var origin     = new Vector3D(0, 0, 0);
            var planePoint = new Vector3D(1, 1, 0);
            var pointA     = new Vector3D(2, 0, 0);
            var pointB     = new Vector3D(0, 2, 0);
            var distanceFromOriginAtTheBase           = Vector3D.AbsoluteValue(planePoint - origin);
            var distanceFromOriginAtTheBaseOnTheXAxis = distanceFromOriginAtTheBase / Sin(45.0.ToRadian());
            var pointOnXAxisOnTheBase   = new Vector3D(distanceFromOriginAtTheBaseOnTheXAxis, 0.0, 0.0);
            var horizontalDistanceAtTop = Sqrt(8);
            var halfDistanceAtTop       = horizontalDistanceAtTop / 2;
            var horizontalDirection     = (planePoint - pointOnXAxisOnTheBase).Normalize();
            var halfPoint         = (0, 0, 2);
            var verticalDistance  = Vector3D.AbsoluteValue(planePoint - halfPoint);
            var verticalDirection = (planePoint - halfPoint).Normalize();
            var horizontalJumps   = Numpy.LinSpace(0, horizontalDistanceAtTop, xLimit).ToList();
            var verticalJumps     = Numpy.LinSpace(0, verticalDistance, yLimit).ToList();
            var midPoint          = (pointA + (horizontalJumps[xLimit / 2] * horizontalDirection)) + (verticalJumps[yLimit / 2] * verticalDirection);
            var mainDirection     = origin - midPoint;

            foreach (var horizontalJump in horizontalJumps)
            {
                var point = pointA + (horizontalJump * horizontalDirection);
                foreach (var verticalJump in verticalJumps)
                {
                    var finalPoint = point + (verticalJump * verticalDirection);
                    var direction  = RotateVector3D(mainDirection.X, mainDirection.Y, mainDirection.Z, alpha.ToRadian());
                    yield return(Line.FromPointAndDirection(finalPoint, direction));
                }
            }
        }
Пример #3
0
        private static IEnumerable <Line> OctoSphereStart(double alpha, int xLimit, int yLimit)
        {
            var xPoint   = new Vector3D(2, 0, 0);
            var yPoint   = new Vector3D(0, 2, 0);
            var topPoint = new Vector3D(0, 0, 2);

            var distance         = Vector3D.AbsoluteValue(yPoint - xPoint);
            var bottomLine       = new Line(xPoint, yPoint);
            var bottomPoint      = bottomLine.GetPointOnLine(distance / 2);
            var verticalDistance = Vector3D.AbsoluteValue(bottomPoint - topPoint);

            var horizontalDirection = (yPoint - xPoint).Normalize();
            var verticalDirection   = (topPoint - bottomPoint).Normalize();
            var mainDirection       = -1 * (new Plane(xPoint, yPoint, topPoint).NormalVector);

            var horizontalJumps = Numpy.LinSpace(0, distance, xLimit);
            var verticalJumps   = Numpy.LinSpace(0, verticalDistance, yLimit);

            foreach (var horizontalJump in horizontalJumps)
            {
                var horiPoint = xPoint + (horizontalJump * horizontalDirection);
                foreach (var verticalJump in verticalJumps)
                {
                    var finalPoint = horiPoint + (verticalJump * verticalDirection);
                    var direction  = RotateVector3D(mainDirection.X, mainDirection.Y, mainDirection.Z, alpha.ToRadian());
                    yield return(Line.FromPointAndDirection(finalPoint, direction));
                }
            }
        }
Пример #4
0
        private static IEnumerable <Line> OctoSphereTri()
        {
            const double alpha    = 0.0;
            var          xPoint   = new Vector3D(2, 0, 0);
            var          yPoint   = new Vector3D(0, 2, 0);
            var          topPoint = new Vector3D(0, 0, 2);

            var side1 = Vector3D.AbsoluteValue(yPoint - xPoint);
            var side2 = Vector3D.AbsoluteValue(topPoint - xPoint);
            var side3 = Vector3D.AbsoluteValue(topPoint - yPoint);
            var bigT  = Heron(side1, side2, side3);

            var distance         = Vector3D.AbsoluteValue(yPoint - xPoint);
            var bottomLine       = new Line(xPoint, yPoint);
            var bottomPoint      = bottomLine.GetPointOnLine(distance / 2);
            var verticalDistance = Vector3D.AbsoluteValue(bottomPoint - topPoint);

            var horizontalDirection = (yPoint - xPoint).Normalize();
            var verticalDirection   = (topPoint - bottomPoint).Normalize();
            var mainDirection       = -1 * (new Plane(xPoint, yPoint, topPoint).NormalVector);

            var horizontalJumps = Numpy.LinSpace(0, distance, 500);
            var verticalJumps   = Numpy.LinSpace(0, verticalDistance, 500);

            foreach (var horizontalJump in horizontalJumps)
            {
                var horiPoint = xPoint + (horizontalJump * horizontalDirection);
                foreach (var verticalJump in verticalJumps)
                {
                    var finalPoint = horiPoint + (verticalJump * verticalDirection);
                    var dist1      = Vector3D.AbsoluteValue(finalPoint - xPoint);
                    var dist2      = Vector3D.AbsoluteValue(finalPoint - yPoint);
                    var dist3      = Vector3D.AbsoluteValue(finalPoint - topPoint);

                    var T1 = Heron(side1, dist1, dist2);
                    var T2 = Heron(side2, dist1, dist3);
                    var T3 = Heron(side3, dist2, dist3);
                    var T  = T1 + T2 + T3;

                    var difference = Abs(bigT - T);
                    if (difference >= 0e-5)
                    {
                        yield return(Line.GetInvalid());
                    }
                    else
                    {
                        var direction = RotateVector3D(mainDirection.X, mainDirection.Y, mainDirection.Z, alpha.ToRadian());
                        yield return(Line.FromPointAndDirection(finalPoint, direction));
                    }
                }
            }
        }
Пример #5
0
        private static IEnumerable <Line> CreateCylinderStartLines(double alpha, int zLimit, int yLimit, double quarter)
        {
            var inRadian = alpha.ToRadian();
            var dz       = Tan(inRadian);
            var r        = Sqrt(Pow(CausticCylinder.R, 2) - Pow(CausticCylinder.R / quarter, 2));
            var zRange   = Numpy.LinSpace(-r, r, zLimit).ToList();
            var yRange   = Numpy.LinSpace(0, CausticCylinder.L, yLimit).ToList();

            foreach (var z in zRange)
            {
                foreach (var y in yRange)
                {
                    if (Abs(Abs(z) - Abs(r)) <= 5e-5 || Abs(y) <= 5e-5 || Abs(y - CausticCylinder.L) <= 5e-5)
                    {
                        continue;
                    }
                    yield return(Line.FromPointAndDirection((-CausticCylinder.R / quarter, y, z), (-1, 0, dz)));
                }
            }
        }
Пример #6
0
        private static IEnumerable <Line> SphereStart(double alpha, int xLimit, int yLimit)
        {
            var inRadian = alpha.ToRadian();
            var dx       = Tan(inRadian);
            var xRange   = Numpy.LinSpace(-1, 1, xLimit).ToList();
            var yRange   = Numpy.LinSpace(-1, 1, yLimit).ToList();

            foreach (var x in xRange)
            {
                foreach (var y in yRange)
                {
                    if (x * x + y * y >= 1)
                    {
                        continue;
                    }

                    yield return(Line.FromPointAndDirection((x - dx, y, 2), (dx, 0, -1)));
                }
            }
        }