Beispiel #1
0
        public PointType NormalToWorld(PointType normal)
        {
            normal   = Transform.Inverse().Transpose() * normal;
            normal.W = 0;
            normal   = normal.Normalize();

            if (HasParent)
            {
                normal = Parent.NormalToWorld(normal);
            }

            return(normal);
        }
Beispiel #2
0
        public static Matrix ViewTransform(PointType from, PointType to, PointType up)
        {
            var forward = (to - from).Normalize();
            var left    = PointType.CrossProduct(forward, up.Normalize());
            var trueUp  = PointType.CrossProduct(left, forward);

            var orientation = new Matrix(4, 4);

            orientation.SetRow(0, new double[] { left.X, left.Y, left.Z, 0 });
            orientation.SetRow(1, new double[] { trueUp.X, trueUp.Y, trueUp.Z, 0 });
            orientation.SetRow(2, new double[] { -forward.X, -forward.Y, -forward.Z, 0 });
            orientation.SetRow(3, new double[] { 0, 0, 0, 1 });
            var t = Translation(-from.X, -from.Y, -from.Z);

            return(orientation * t);
        }