Exemple #1
0
        internal static IPoint3D GetClosestPointToFictiousLine(IPoint3D p, IPoint3D lineStart, IPoint3D lineEnd)
        {
            IVector3D direction  = lineEnd - lineStart;
            IVector3D projection = lineStart - p;
            IPoint3D  pos;
            double    t = IVector3D.Dot(projection, direction);

            if (t <= 0)
            {
                return(lineStart);
            }
            else
            {
                double eval = Math.Pow(lineStart.DistanceTo(lineEnd), 2);
                if (t >= eval)
                {
                    return(lineEnd);
                }
                else
                {
                    t   = t / eval;
                    pos = new IPoint3D();
                    direction.Mult(t);
                    pos = lineStart + direction;
                    return(pos);
                }
            }
        }
Exemple #2
0
        public void Mirror(IPlane plane)
        {
            IVector3D n         = plane.Normal;
            IMatrix   tensor    = n.TensorProduct(n);
            double    dot_plane = IVector3D.Dot(plane.Origin, n);

            double[][] data = new double[4][];
            data[0] = new double[] { 1 - 2 * tensor.GetData(0, 0), -2 * tensor.GetData(0, 1), -2 * tensor.GetData(0, 2), 0 };
            data[1] = new double[] { -2 * tensor.GetData(1, 0), 1 - 2 * tensor.GetData(1, 1), -2 * tensor.GetData(1, 2), 0 };
            data[2] = new double[] { -2 * tensor.GetData(2, 0), -2 * tensor.GetData(2, 1), 1 - 2 * tensor.GetData(2, 2), 0 };
            data[3] = new double[] { 2 * dot_plane * n.X, 2 * dot_plane * n.Y, 2 * dot_plane * n.Z, 1 };
            IMatrix m = new IMatrix(data);

            TransformationMatrix = IMatrix.Mult(TransformationMatrix, m);
        }