Exemplo n.º 1
0
        private static void GetNextOrthonormalizedVectors(Vector3D circle1OrtVec, Vector3D circle2OrtVec, Vector3D circle1V1, Vector3D circle1V2,
                                                          out Vector3D circle2V1, out Vector3D circle2V2)
        {
            Vector3D commonVec = Vector3D.CrossProduct(circle1OrtVec, circle2OrtVec);

            if (commonVec.Abs() < 1e-8)
            {
                circle2V1 = circle1V1;
                circle2V2 = circle1V2;
                return;
            }

            commonVec.Normalize();
            Vector3D circle1AuxVec = Vector3D.CrossProduct(commonVec, circle1OrtVec).Normalize();
            Vector3D circle2AuxVec = Vector3D.CrossProduct(commonVec, circle2OrtVec).Normalize();

            double coef1, coef2;

            ExpressVector(circle1V1, commonVec, circle1AuxVec, out coef1, out coef2);
            circle2V1 = (commonVec * coef1 + circle2AuxVec * coef2).Normalize();
            ExpressVector(circle1V2, commonVec, circle1AuxVec, out coef1, out coef2);
            circle2V2 = (commonVec * coef1 + circle2AuxVec * coef2).Normalize();
        }
Exemplo n.º 2
0
        public void AddPolygon(Point3D[] points)
        {
            if (points.Length < 3)
            {
                throw new ArgumentException("points.Length < 3");
            }

            Point3D innerPoint = new Point3D {
                X = points.Average(p => p.X), Y = points.Average(p => p.Y), Z = points.Average(p => p.Z)
            };
            Vector3D ortVec = Vector3D.CrossProduct(innerPoint - points[0], points[1] - points[0]);
            Plane    plane  = new Plane(ortVec, points[0]);

            Plane[] ortPlanes = new Plane[points.Length];

            for (int n = 0; n < points.Length; n++)
            {
                ortPlanes[n] = new Plane(Vector3D.CrossProduct(points[(n + 1) % points.Length] - points[n], ortVec), points[n]);
                ortPlanes[n].Normalize();
            }

            AddRayTracedObject(points, (int xProj, int yProj, double eyeXPos, out double x, out double z) =>
                               GetPlaneRayIntersection(xProj, yProj, eyeXPos, plane.A, plane.B, plane.C, plane.D, out x, out z, (x1, y1, z1) => ortPlanes.All(p => p.A * x1 + p.B * y1 + p.C * z1 + p.D > -1e-8)));
        }
Exemplo n.º 3
0
 private static void GetSomeOrthonormalizedVectors(Vector3D ortVec, out Vector3D v1, out Vector3D v2)
 {
     v1 = ortVec.GetSomeOrtVector().Normalize();
     v2 = Vector3D.CrossProduct(ortVec, v1).Normalize();
 }