Permalink
Cannot retrieve contributors at this time
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?
RangeSearch/App/Quaternion.pde
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
43 lines (37 sloc)
854 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |