29 #include "LinearMath/btScalar.h"
30 #include "LinearMath/btVector3.h"
31 #include "LinearMath/btQuaternion.h"
42 int main(
int argc,
char** argv)
44 btVector3 point1(atof(argv[1]), atof(argv[2]), atof(argv[3]));
45 btVector3 point2(atof(argv[4]), atof(argv[5]), atof(argv[6]));
47 btVector3 point3(atof(argv[7]), atof(argv[8]), atof(argv[9]));
49 btVector3 normal(atof(argv[10]), atof(argv[11]), atof(argv[12]));
51 btVector3 point4(0.0, 0.0, 0.0);
53 std::cout << point1 <<
" " << point2 <<
" " << point3 << std::endl;
55 std::cout <<
"new point " << (point3 - point1).dot(point2) << std::endl;
56 std::cout <<
"old point " << (point3 - point1).dot(point3) << std::endl;
58 btVector3 lineA = point3 - point2;
59 btVector3 lineB = point1 - point2;
64 btVector3 tangentDir =( (lineB - lineA).cross(normal)).normalize();
65 btVector3 tangentMove = (lineB + lineA).dot(tangentDir) * tangentDir / 2.0;
66 btVector3 newPos = point2 + tangentMove;
68 std::cout <<
"tangentDir " << tangentDir << std::endl;
69 std::cout <<
"tangentMove " << tangentMove << std::endl;
70 std::cout <<
"newPos " << newPos << std::endl;
76 btVector3 lineACopy = lineA;
77 btVector3 lineBCopy = lineB;
78 btVector3 ab = lineA + lineB;
79 btVector3 abNorm = (lineACopy.normalize() + lineBCopy.normalize()).normalize();
82 btVector3 AN = lineA.dot(normal) * lineACopy.normalize();
83 btVector3 BN = lineB.dot(normal) * lineBCopy.normalize();
84 btVector3 normalProjection = abNorm.dot(normal) * abNorm;
86 normalProjection.normalize();
88 std::cout <<
"lineA Norm: " << lineACopy << std::endl;
89 std::cout <<
"lineB Norm: " << lineBCopy << std::endl;
90 std::cout <<
"Normal: " << normal << std::endl;
91 std::cout <<
"Projection: " << normalProjection << std::endl;
92 std::cout <<
"Angle AN: " << lineA.angle(normalProjection) << std::endl;
93 std::cout <<
"Angle BN " << lineB.angle(normalProjection) << std::endl;
94 std::cout <<
"Sum AN + BN " << lineA.angle(normalProjection) + lineB.angle(normalProjection) << std::endl;
95 std::cout <<
"Angle AB " << lineA.angle(lineB) << std::endl;
97 std::cout <<
"Angle normal w/ x axis " << btVector3(1.0, 0.0, 0.0).angle(normal) << std::endl;
98 std::cout <<
"Angle lineA w/ x axis " << btVector3(1.0, 0.0, 0.0).angle(lineA) << std::endl;
99 std::cout <<
"Angle lineB w/ x axis " << btVector3(1.0, 0.0, 0.0).angle(lineB) << std::endl;
101 std::cout <<
"Traditional: " << lineA.dot(normal) <<
" " << lineB.dot(normal) << std::endl;
int main(int argc, char **argv)
static btQuaternion getQuaternionBetween(btVector3 a, btVector3 b)
Contains the definition of class tgUtil and overloaded operator<<() free functions.