lineManip/manipulatorMath.cpp
         
    
#include <maya/MPoint.h>
#include <maya/MVector.h>
#include "manipulatorMath.h"
planeMath::planeMath()
{
    a = b = c = d = 0.0;
}
bool planeMath::setPlane( 
const MPoint& pointOnPlane, 
const MVector& normalToPlane )
 
{
    MVector _normalToPlane = normalToPlane;
 
    
    d = -(a*pointOnPlane.
x + b*pointOnPlane.
y + c*pointOnPlane.
z);
    return true;
}
bool planeMath::intersect( 
const MPoint& linePoint, 
const MVector& lineDirection, 
MPoint& intersectionPoint )
 
{
    double denominator = a*lineDirection.
x + b*lineDirection.
y + c*lineDirection.
z;
 
    
    if(denominator < .00001)
    {
        return false;
    }
    double t = -(d + a*linePoint.
x + b*linePoint.
y + c*linePoint.
z) / denominator;
 
    
    intersectionPoint = linePoint + t * lineDirection;
    return true;
}
lineMath::lineMath()
{
    
}
bool lineMath::setLine( 
const MPoint& linePoint, 
const MVector& lineDirection )
 
{
    point = linePoint;
    direction = lineDirection;
    return true;
}
bool lineMath::closestPoint( 
const MPoint& toPoint, 
MPoint& closest )
 
{
    double t = direction * ( toPoint - point );
    closest = point + ( direction * t );
    return true;
}
double DegreeRadianConverter::degreesToRadians( double degrees )
{
     return degrees * ( M_PI/ 180.0 );
}
double DegreeRadianConverter::radiansToDegrees( double radians )
{
    return radians * (180.0/M_PI);
}