]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Quaternions.cpp
Added GPL license and headers.
[lugaru.git] / Source / Quaternions.cpp
index ab9034d7448130a1b9282f4c87a7ab4f9f0a54da..08394e1a93b4a67f8079eab252822306f7770f58 100644 (file)
@@ -1,3 +1,24 @@
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*/
+
 #include "Quaternions.h"
 
 // Functions
@@ -275,7 +296,7 @@ bool LineFacet(Vector p1,Vector p2,Vector pa,Vector pb,Vector pc,Vector *p)
 
        //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);
-       if (abs(denom) < 0.0000001)        // Line and plane don't intersect 
+       if (fabs(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;
        p->x = p1.x + mu * (p2.x - p1.x);
@@ -382,7 +403,7 @@ bool LineFacet(XYZ p1,XYZ p2,XYZ pa,XYZ pb,XYZ pc,XYZ *p)
 
        //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);
-       if (abs(denom) < 0.0000001)        // Line and plane don't intersect 
+       if (fabs(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;
        p->x = p1.x + mu * (p2.x - p1.x);
@@ -412,7 +433,7 @@ float LineFacetd(XYZ p1,XYZ p2,XYZ pa,XYZ pb,XYZ pc,XYZ *p)
 
        //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);
-       if (abs(denom) < 0.0000001)        // Line and plane don't intersect 
+       if (fabs(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;
        p->x = p1.x + mu * (p2.x - p1.x);
@@ -438,7 +459,7 @@ float LineFacetd(XYZ p1,XYZ p2,XYZ pa,XYZ pb,XYZ pc, XYZ n, XYZ *p)
 
        //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);
-       if (abs(denom) < 0.0000001)        // Line and plane don't intersect 
+       if (fabs(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;
        p->x = p1.x + mu * (p2.x - p1.x);
@@ -468,7 +489,7 @@ float LineFacetd(XYZ *p1,XYZ *p2,XYZ *pa,XYZ *pb,XYZ *pc, XYZ *p)
 
        //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);
-       if (abs(denom) < 0.0000001)        // Line and plane don't intersect 
+       if (fabs(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;
        p->x = p1->x + mu * (p2->x - p1->x);
@@ -493,7 +514,7 @@ float LineFacetd(XYZ *p1,XYZ *p2,XYZ *pa,XYZ *pb,XYZ *pc, XYZ *n, XYZ *p)
 
        //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);
-       if (abs(denom) < 0.0000001)        // Line and plane don't intersect 
+       if (fabs(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;
        p->x = p1->x + mu * (p2->x - p1->x);
@@ -506,3 +527,4 @@ float LineFacetd(XYZ *p1,XYZ *p2,XYZ *pa,XYZ *pb,XYZ *pc, XYZ *n, XYZ *p)
        return 1;
 }
 
+