当前位置: 首页>>代码示例>>C#>>正文


C# Matrix3D.InvertCore方法代码示例

本文整理汇总了C#中System.Windows.Media.Media3D.Matrix3D.InvertCore方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix3D.InvertCore方法的具体用法?C# Matrix3D.InvertCore怎么用?C# Matrix3D.InvertCore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Media3D.Matrix3D的用法示例。


在下文中一共展示了Matrix3D.InvertCore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrependInverseTransform

 // Helper method to prepend the inverse of Camera.Transform to the
 // the given viewMatrix.  This is used by the various GetViewMatrix()
 // and RayFromViewportPoint implementations.
 // 
 // Transforming the camera is equivalent to applying the inverse
 // transform to the scene.  We invert the transform and prepend it to 
 // the result of viewMatrix: 
 //
 //                                  -1 
 //     viewMatrix = Camera.Transform   x viewMatrix
 //
 // If the matrix is non-invertable we set the viewMatrix to NaNs which
 // will result in nothing being rendered.  This is the correct behavior 
 // since the near and far planes will have collapsed onto each other.
 internal static void PrependInverseTransform(Matrix3D matrix, ref Matrix3D viewMatrix) 
 { 
     if (!matrix.InvertCore())
     { 
         // If the matrix is non-invertable we return a NaN matrix.
         viewMatrix = new Matrix3D(
             double.NaN, double.NaN, double.NaN, double.NaN,
             double.NaN, double.NaN, double.NaN, double.NaN, 
             double.NaN, double.NaN, double.NaN, double.NaN,
             double.NaN, double.NaN, double.NaN, double.NaN); 
     } 
     else
     { 
         viewMatrix.Prepend(matrix);
     }
 }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:30,代码来源:Camera.cs

示例2: Transform

        public static void Transform(Matrix3D modelMatrix,
                                     ref Point3D origin, ref Vector3D direction, out bool isRay)
        {
            if (modelMatrix.InvertCore())
            {
                Point4D o = new Point4D(origin.X,origin.Y,origin.Z,1);
                Point4D d = new Point4D(direction.X,direction.Y,direction.Z,0);
                
                modelMatrix.MultiplyPoint(ref o);
                modelMatrix.MultiplyPoint(ref d);

                if (o.W == 1 && d.W == 0)
                {
                    // Affine transformation
                    
                    origin = new Point3D(o.X, o.Y, o.Z);
                    direction = new Vector3D(d.X, d.Y, d.Z);

                    isRay = true;
                }
                else
                {
                    // Non-affine transformation (likely projection)
                    
                    // Form 4x2 matrix with two points on line in two columns.
                    double[,] linepoints = new double[,]{{o.X,d.X},{o.Y,d.Y},{o.Z,d.Z},{o.W,d.W}};
                    
                    ColumnsToAffinePointVector(linepoints,0,1,out origin, out direction);

                    isRay = false;
                }
            }
            else
            {
                TransformSingular(ref modelMatrix, ref origin, ref direction);

                isRay = false;
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:39,代码来源:LineUtil.cs


注:本文中的System.Windows.Media.Media3D.Matrix3D.InvertCore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。