The function mrotate(double, double, double, double) does not exist.
in
Programming Questions
•
2 years ago
I'm working on avoiding gimbal lock, i found some java code here which i want to use to give it a try.
http://www.java-gaming.org/index.php?action=printpage;topic=19261.0
I allready changed some things but now i get the error:
The function mrotate(double, double, double, double) does not exist.
why? cause the function does exist.
http://www.java-gaming.org/index.php?action=printpage;topic=19261.0
I allready changed some things but now i get the error:
The function mrotate(double, double, double, double) does not exist.
why? cause the function does exist.
- Point3D p;
double one = 1.0;
void setup() {
p =new Point3D();
p.x=200;
p.y=100;
p.y=50;
//p.mrotate(Math.PI*0.25, 1.0, 1.0, 1.0);//gives a float error casue double is needed
p.mrotate(Math.PI*0.25, one, one, one);
}
void draw() {
}
public class Point3D {
public double x,y,z;
Point3D() {
//empty constructor
}
public mrotate(double angle,double x,double y,double z)
{
//normalize axis in case of
double n=Math.sqrt(x*x+y*y+z*z);
if(n==0.0) return this;
double in=1.0/n;
x*=in;
y*=in;
z*=in;
double nzx=Math.sqrt(x*x+z*z);
double rx=Math.asin(y);
double ry=0;
if(nzx!=0.0)
{
ry=-Math.acos(z/nzx);
if(x<0)
ry=-ry;
}
else
{
if(y>0)
rx=Math.PI*0.5;
else
rx=-Math.PI*0.5;
ry=0;
}
//Add here the -T translation for arbitrary axis (not starting at 0,0,0)
this.rotateY(-ry);
this.rotateX(-rx);
this.rotateZ(angle);
this.rotateX(rx);
this.rotateY(ry);
//Add here the +T translation for arbitrary axis (not starting at 0,0,0)
return this;
}
//rotate around world x axis
public mrotateX(double angle)
{
double tY=y,tZ=z;
double cosa=Math.cos(angle);
double sina=Math.sin(angle);
y=tY*cosa + tZ*sina;
z=-tY*sina + tZ*cosa;
return this;
}
//rotate around world y axis
public mrotateY(double angle)
{
double tX=x,tZ=z;
double cosa=Math.cos(angle);
double sina=Math.sin(angle);
x=tX*cosa - tZ*sina;
z=tX*sina + tZ*cosa;
return this;
}
//rotate around world z axis
public mrotateZ(double angle)
{
double tY=y,tX=x;
double cosa=Math.cos(angle);
double sina=Math.sin(angle);
x=tX*cosa + tY*sina;
y=-tX*sina + tY*cosa;
return this;
}
// add method
public plus(Point3D p)
{
this.x+=p.x;
this.y+=p.y;
this.z+=p.z;
}
//sub method
public sub(Point3D p)
{
this.x-=p.x;
this.y-=p.y;
this.z-=p.z;
}
}
1