Skip to content
Permalink
b9087497bc
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
43 lines (37 sloc) 854 Bytes
public class Quat {
float w, x, y, z;
//Default Constructor
public Quat () {
w = 1.0;
x = 0.0;
y = 0.0;
z = 0.0;
}
public Quat (float w0, x0, y0, z0) {
w = w0;
x = x0;
y = y0;
z = z0;
}
public Quat add (Quat q) {
float nw = w + q.w;
float nx = x + q.x;
float ny = y + q.y;
float nz = z + q.z;
return new Quat (nw, nx, ny, nz);
}
public Quat mult (Quat q) {
float nw = w * q.w - (x * q.x + y * q.y + z * q.z);
float nx = w * q.w + x * q.x + y * q.y - z * q.z;
float ny = w * q.w - x * q.x + y * q.y + z * q.z;
float nz = q * q.w + x * q.x - y * q.y + z * q.z;
return new Qua (nw, nx, ny, nz);
}
public Quat scale (float t) {
float nw = t * q;
float nx = t * x;
float ny = t * y;
float nz = t * z;
return new Quat (nw, ny, nz);
}
}