47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#include "emath_opengl.h"
|
|
|
|
void rotFrom2VecTo2Vec(Punkt3D a, Punkt3D b, Punkt3D c, Punkt3D d, Punkt3D *rvec, float *rvecdeg, Punkt3D *rvec2, float *rvecdeg2) {
|
|
Punkt3D rotvec, rotvec2, nullvec;
|
|
float rotvecdeg = 0.0f, rotvecdeg2 = 0.0f;
|
|
|
|
rotvec = a.kreuzprodukt(b);
|
|
rotvecdeg = a.calcAngle(b);
|
|
if(std::abs(rotvecdeg)==180.0f) {
|
|
rotvec = a.getOrtographic();
|
|
}
|
|
|
|
if(rotvec==nullvec) {
|
|
rotvec.set(1.0f, 0.0f, 0.0f);
|
|
rotvecdeg = 0.0f;
|
|
}
|
|
|
|
Rotationsmatrix rotnobj(rotvec, -rotvecdeg);
|
|
c = Rotationsmatrix(rotvec, rotvecdeg) * c;
|
|
|
|
rotvec2 = c.kreuzprodukt(d);
|
|
rotvecdeg2 = c.calcAngle(d);
|
|
if(std::abs(rotvecdeg2)==180.0f) {
|
|
rotvec2 = b;
|
|
}
|
|
|
|
if(rotvec2==nullvec) {
|
|
rotvec2.set(1.0f, 0.0f, 0.0f);
|
|
rotvecdeg2 = 0.0f;
|
|
}
|
|
|
|
rotvec2 = rotnobj * rotvec2;
|
|
|
|
*rvec = rotvec;
|
|
*rvecdeg = rotvecdeg;
|
|
*rvec2 = rotvec2;
|
|
*rvecdeg2 = rotvecdeg2;
|
|
}
|
|
|
|
void rotFrom2VecTo2Vec(Punkt3D a, Punkt3D b, Punkt3D c, Punkt3D d) {
|
|
Punkt3D rvec, rvec2;
|
|
float rvecdeg, rvecdeg2;
|
|
rotFrom2VecTo2Vec(a, b, c, d, &rvec, &rvecdeg, &rvec2, &rvecdeg2);
|
|
glRotatef(rvecdeg, rvec);
|
|
glRotatef(rvecdeg2, rvec2);
|
|
}
|