/// <summary>
 /// Gets the tangent plane at the specified position
 /// </summary>
 public Plane3 GetTangentPlaneUnderPoint( UniPoint3 pos, out Point3 pointOnPlane )
 {
     Vector3 normal = Planet.Transform.Position.VectorTo( pos ).MakeNormal( );
     Vector3 vec = normal * ( Planet.Model.Radius + m_GeometryRadius ).ToRenderUnits;
     pointOnPlane = vec.ToPoint3( );
     return new Plane3( pointOnPlane, normal );
 }
 /// <summary>
 /// Sets the coordinate frame
 /// </summary>
 public void Set( UniPoint3 pt, Vector3 xAxis, Vector3 yAxis, Vector3 zAxis )
 {
     Position = pt;
     m_Axis[ 0 ] = xAxis;
     m_Axis[ 1 ] = yAxis;
     m_Axis[ 2 ] = zAxis;
 }
 /// <summary>
 /// Copy constructor
 /// </summary>
 public UniPoint3( UniPoint3 src )
 {
     m_X = src.m_X;
     m_Y = src.m_Y;
     m_Z = src.m_Z;
 }
        public Vector3 VectorTo( UniPoint3 pt )
        {
            double vecX = ( pt.m_X - m_X );
            double vecY = ( pt.m_Y - m_Y );
            double vecZ = ( pt.m_Z - m_Z );

            double invLength = 1.0 / Math.Sqrt( vecX * vecX + vecY * vecY + vecZ * vecZ );
            return new Vector3( ( float )( vecX * invLength ), ( float )( vecY * invLength ), ( float )( vecZ * invLength ) );
        }
        public long SqrDistanceTo( UniPoint3 pt )
        {
            long diffX = ( m_X - pt.m_X );
            long diffY = ( m_Y - pt.m_Y );
            long diffZ = ( m_Z - pt.m_Z );

            return ( diffX * diffX + diffY * diffY + diffZ * diffZ );
        }
        public long ManhattanDistanceTo( UniPoint3 pt )
        {
            long diffX = ( m_X - pt.m_X );
            long diffY = ( m_Y - pt.m_Y );
            long diffZ = ( m_Z - pt.m_Z );

            return ( diffX < 0 ? -diffX : diffX ) + ( diffY < 0 ? -diffY : diffY ) + ( diffZ < 0 ? -diffZ : diffZ );
        }
 public double DistanceTo( UniPoint3 pt )
 {
     return Math.Sqrt( SqrDistanceTo( pt ) );
 }
 /// <summary>
 /// Copies another vector
 /// </summary>
 public void Copy( UniPoint3 src )
 {
     m_X = src.m_X;
     m_Y = src.m_Y;
     m_Z = src.m_Z;
 }
 /// <summary>
 /// Gets the tangent space matrix at the specified position
 /// </summary>
 public Matrix44 GetTangentSpaceUnderPoint( UniPoint3 pos )
 {
     throw new NotImplementedException( );
 }
 /// <summary>
 /// Setup constructor
 /// </summary>
 public UniRay3( UniPoint3 origin, Vector3 dir )
 {
     m_Origin = origin;
     m_Direction = dir;
 }
 /// <summary>
 /// Default constructor. Places the ray at the origin, pointing along the z axis
 /// </summary>
 public UniRay3( )
 {
     m_Origin = new UniPoint3( );
     m_Direction = Vector3.ZAxis;
 }