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


C# Vector3f.Normalized方法代码示例

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


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

示例1: RotateAxis

        public static Matrix3f RotateAxis( Vector3f axis, float radians )
        {
            var normalizedAxis = axis.Normalized();
            float cosTheta = ( float )( Math.Cos( radians ) );
            float sinTheta = ( float )( Math.Sin( radians ) );

            float x = normalizedAxis.x;
            float y = normalizedAxis.y;
            float z = normalizedAxis.z;

            var m = new Matrix3f();

            m[ 0, 0 ] = x * x * ( 1.0f - cosTheta ) + cosTheta;
            m[ 0, 1 ] = y * x * ( 1.0f - cosTheta ) - z * sinTheta;
            m[ 0, 2 ] = z * x * ( 1.0f - cosTheta ) + y * sinTheta;

            m[ 1, 0 ] = x * y * ( 1.0f - cosTheta ) + z * sinTheta;
            m[ 1, 1 ] = y * y * ( 1.0f - cosTheta ) + cosTheta;
            m[ 1, 2 ] = z * y * ( 1.0f - cosTheta ) - x * sinTheta;

            m[ 2, 0 ] = x * z * ( 1.0f - cosTheta ) - y * sinTheta;
            m[ 2, 1 ] = y * z * ( 1.0f - cosTheta ) + x * sinTheta;
            m[ 2, 2 ] = z * z * ( 1.0f - cosTheta ) + cosTheta;

            return m;
        }
开发者ID:jiawen,项目名称:libcgt.net,代码行数:26,代码来源:Matrix3f.cs

示例2: Camera

        public Camera(Vector3f position, Vector3f forward, Vector3f worldUp, float fieldOfView, Size renderSize)
            : base(position)
        {
            this.ReflectionDepth = 5;
            this.forward = forward.Normalized();
            this.right = Util.CrossProduct(worldUp, forward).Normalized();
            this.up = -Util.CrossProduct(right, forward).Normalized();
            this.fieldOfView = fieldOfView;
            this.RenderSize = renderSize;

            RecalculateFieldOfView();
        }
开发者ID:FrenchData,项目名称:dotnetsamples,代码行数:12,代码来源:Camera.cs

示例3: Plane

        /// <summary>
        /// Constructs a plane with the properties provided
        /// </summary>
        /// <param name="position">The position of the plane's center</param>
        /// <param name="material">The plane's material</param>
        /// <param name="normalDirection">The normal direction of the plane</param>
        /// <param name="cellWidth">The width of a cell in the plane, used for texture coordinate mapping.</param>
        public Plane(Vector3f position, Material material, Vector3f normalDirection, float cellWidth)
            : base(position, material)
        {
            this.normalDirection = normalDirection.Normalized();
            if (normalDirection == Util.ForwardVector)
            {
                this.uDirection = -Util.RightVector;
            }
            else if (normalDirection == -Util.ForwardVector)
            {
                this.uDirection = Util.RightVector;
            }
            else
            {
                this.uDirection = Util.CrossProduct(normalDirection, Util.ForwardVector).Normalized();
            }

            this.vDirection = -Util.CrossProduct(normalDirection, uDirection).Normalized();
            this.cellWidth = cellWidth;
        }
开发者ID:FrenchData,项目名称:dotnetsamples,代码行数:27,代码来源:Plane.cs

示例4: Basis

        /// <summary>
        /// Returns an orthonormal basis u, v, and n on the plane
        /// given a preferred u vector.  If u is not on the plane,
        /// then u is projected onto the plane first
        /// </summary>
        /// <param name="u"></param>
        /// <returns></returns>
        public Matrix3f Basis( Vector3f u )
        {
            // normalize u first
            u = u.Normalized();
            var n = UnitNormal;

            // u is the vector triple product: ( n x u ) x n
            //
            // u is the preferred direction, which may be be in the plane
            // we want u to be the projection of u in the plane
            // and v to be perpendicular to both
            // but v is n cross u regardless of whether u is in the plane or not
            // so compute v, then cross v with n to get u in the plane
            var v = Vector3f.Cross( n, u ).Normalized();
            u = Vector3f.Cross( v, n ).Normalized();

            return new Matrix3f( u, v, n );
        }
开发者ID:jiawen,项目名称:libcgt.net,代码行数:25,代码来源:Plane4f.cs

示例5: Plane3f

 /// <summary>
 /// Construct a plane given a point on the plane and its normal (does not need to be unit length)
 /// </summary>
 /// <param name="p"></param>
 /// <param name="normal"></param>
 public Plane3f( Vector3f p, Vector3f normal )
 {
     var unitNormal = normal.Normalized();
     var d = -Vector3f.Dot( unitNormal, p );
     ABCD = new Vector4f( unitNormal, d );
 }
开发者ID:jiawen,项目名称:libcgt.net,代码行数:11,代码来源:Plane3f.cs

示例6: Projection

 public static Vector3f Projection(Vector3f projectedVector, Vector3f directionVector)
 {
     var mag = VectorMath.DotProduct(projectedVector, directionVector.Normalized());
     return directionVector * mag;
 }
开发者ID:FrenchData,项目名称:dotnetsamples,代码行数:5,代码来源:Util.cs

示例7: Ray

 public Ray(Vector3f start, Vector3f direction, float distance)
 {
     this.Origin = start;
     this.Direction = direction.Normalized();
     this.Distance = distance;
 }
开发者ID:FrenchData,项目名称:dotnetsamples,代码行数:6,代码来源:Ray.cs


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