diff options
Diffstat (limited to 'src/Quaternions.cpp')
-rw-r--r-- | src/Quaternions.cpp | 54 |
1 files changed, 3 insertions, 51 deletions
diff --git a/src/Quaternions.cpp b/src/Quaternions.cpp index 2c01da9..9b32dc0 100644 --- a/src/Quaternions.cpp +++ b/src/Quaternions.cpp @@ -52,22 +52,17 @@ bool PointInTriangle(XYZ *p, XYZ normal, XYZ *p1, XYZ *p2, XYZ *p3) return bInter; } -extern float d; -extern float a1,a2,a3; -extern float total,denom,mu; -extern XYZ pa1,pa2,pa3,n; - float LineFacetd(XYZ p1,XYZ p2,XYZ pa,XYZ pb,XYZ pc, XYZ n, XYZ *p) { //Calculate the parameters for the plane - d = - n.x * pa.x - n.y * pa.y - n.z * pa.z; + float d = - n.x * pa.x - n.y * pa.y - n.z * pa.z; //Calculate the position on the line that intersects the plane - denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z); + float denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z); if (abs(denom) < 0.0000001) // Line and plane don't intersect return 0; - mu = - (d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom; + float mu = - (d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom; p->x = p1.x + mu * (p2.x - p1.x); p->y = p1.y + mu * (p2.y - p1.y); p->z = p1.z + mu * (p2.z - p1.z); @@ -77,46 +72,3 @@ float LineFacetd(XYZ p1,XYZ p2,XYZ pa,XYZ pb,XYZ pc, XYZ n, XYZ *p) if(!PointInTriangle( p, n, &pa, &pb, &pc)){return 0;} return 1; } - -float findDistance(XYZ point1, XYZ point2){ - return sqrt((point1.x-point2.x)*(point1.x-point2.x)+(point1.y-point2.y)*(point1.y-point2.y)+(point1.z-point2.z)*(point1.z-point2.z)); -} - -XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang){ - XYZ newpoint; - if(xang){ - xang*=6.283185; - xang/=360; - } - if(yang){ - yang*=6.283185; - yang/=360; - } - if(zang){ - zang*=6.283185; - zang/=360; - } - - if(yang){ - newpoint.z=thePoint.z*cos(yang)-thePoint.x*sin(yang); - newpoint.x=thePoint.z*sin(yang)+thePoint.x*cos(yang); - thePoint.z=newpoint.z; - thePoint.x=newpoint.x; - } - - if(zang){ - newpoint.x=thePoint.x*cos(zang)-thePoint.y*sin(zang); - newpoint.y=thePoint.y*cos(zang)+thePoint.x*sin(zang); - thePoint.x=newpoint.x; - thePoint.y=newpoint.y; - } - - if(xang){ - newpoint.y=thePoint.y*cos(xang)-thePoint.z*sin(xang); - newpoint.z=thePoint.y*sin(xang)+thePoint.z*cos(xang); - thePoint.z=newpoint.z; - thePoint.y=newpoint.y; - } - - return thePoint; -} |