diff options
Diffstat (limited to 'src/Quaternions.cpp')
-rw-r--r-- | src/Quaternions.cpp | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/src/Quaternions.cpp b/src/Quaternions.cpp index 6fe85bf..9142da0 100644 --- a/src/Quaternions.cpp +++ b/src/Quaternions.cpp @@ -2,20 +2,6 @@ #include "Quaternions.h" -void CrossProduct(XYZ P, XYZ Q, XYZ *V){ - V->x = P.y * Q.z - P.z * Q.y; - V->y = P.z * Q.x - P.x * Q.z; - V->z = P.x * Q.y - P.y * Q.x; -} - -void Normalise(XYZ *vectory) { - float d = sqrt(vectory->x*vectory->x+vectory->y*vectory->y+vectory->z*vectory->z); - if(d==0){return;} - vectory->x /= d; - vectory->y /= d; - vectory->z /= d; -} - extern float u0, u1, u2; extern float v0, v1, v2; extern float a, b; @@ -117,30 +103,6 @@ float LineFacetd(XYZ p1,XYZ p2,XYZ pa,XYZ pb,XYZ pc, XYZ n, XYZ *p) return 1; } -void ReflectVector(XYZ *vel, XYZ *n) -{ - XYZ vn; - XYZ vt; - float dotprod; - - dotprod=dotproduct(*n,*vel); - vn.x=n->x*dotprod; - vn.y=n->y*dotprod; - vn.z=n->z*dotprod; - - vt.x=vel->x-vn.x; - vt.y=vel->y-vn.y; - vt.z=vel->z-vn.z; - - vel->x = vt.x - vn.x; - vel->y = vt.y - vn.y; - vel->z = vt.z - vn.z; -} - -float dotproduct(XYZ point1, XYZ point2){ - return point1.x * point2.x + point1.y * point2.y + point1.z * point2.z; -} - 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)); } @@ -191,44 +153,3 @@ XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang){ return thePoint; } - -float square( float f ) { return (f*f) ;} - -bool sphere_line_intersection(float x1, float y1, float z1, - float x2, float y2, float z2, float x3, float y3, float z3, float r) -{ - - // x1,y1,z1 P1 coordinates (point of line) - // x2,y2,z2 P2 coordinates (point of line) - // x3,y3,z3, r P3 coordinates and radius (sphere) - // x,y,z intersection coordinates - // - // This function returns a pointer array which first index indicates - // the number of intersection point, followed by coordinate pairs. - - float a, b, c, i; - - if(x1>x3+r&&x2>x3+r)return(0); - if(x1<x3-r&&x2<x3-r)return(0); - if(y1>y3+r&&y2>y3+r)return(0); - if(y1<y3-r&&y2<y3-r)return(0); - if(z1>z3+r&&z2>z3+r)return(0); - if(z1<z3-r&&z2<z3-r)return(0); - a = square(x2 - x1) + square(y2 - y1) + square(z2 - z1); - b = 2* ( (x2 - x1)*(x1 - x3) - + (y2 - y1)*(y1 - y3) - + (z2 - z1)*(z1 - z3) ) ; - c = square(x3) + square(y3) + - square(z3) + square(x1) + - square(y1) + square(z1) - - 2* ( x3*x1 + y3*y1 + z3*z1 ) - square(r) ; - i = b * b - 4 * a * c ; - - if ( i < 0.0 ) - { - // no intersection - return(0); - } - - return(1); -} |