Normalize() public method

public Normalize ( ) : void
return void
Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="at">Looking direction, must be a normalized vector</param>
        /// <param name="upDirection">Up direction, must be a normalized vector</param>
        public void LookDirection(Vector3f at, Vector3f upDirection)
        {
            // The two parameters cannot be parallel
            Vector3f left = upDirection.Cross(ref at);
            if (left == Vector3f.Zero)
            {
                // Prevent left from being zero
                at.X += 0.01f;
                at.Normalize();
                left = upDirection.Cross(ref at);
            }
            left.Normalize();

            xAxis = at;
            yAxis = left;
            zAxis = at.Cross(ref left);
        }
Exemplo n.º 2
0
 protected void Orthonormalize()
 {
     // Make sure the axis are orthagonal and normalized
     xAxis.Normalize();
     yAxis -= xAxis * (xAxis * yAxis);
     yAxis.Normalize();
     zAxis = xAxis.Cross(ref yAxis);
 }
Exemplo n.º 3
0
        public void FromWorld(Vector3f position, Vector3f forward, Vector3f up)
        {
            // Normalize forward vector
            forward.Normalize();

            // Calculate right vector
            Vector3f right = forward.Cross(ref up);
            right.Normalize();

            // Recalculate up vector
            up = right.Cross(ref forward);
            up.Normalize();

            R0 = new Vector4f(right.X, right.Y, right.Z, 0.0f);
            R1 = new Vector4f(up.X, up.Y, up.Z, 0.0f);
            R2 = new Vector4f(-forward.X, -forward.Y, -forward.Z, 0.0f);
            R3 = new Vector4f(position.X, position.Y, position.Z, 1.0f);
        }