topical media & game development
graphic-processing-algorithm-Ch08-p191-MyPoint.pde / pde
class MyPoint {
float x, y, z;
MyPoint(float xinput, float yinput, float zinput){
x = xinput;
y = yinput;
z = zinput;
}
void move(float xoff, float yoff, float zoff){
x = x + xoff;
y = y + yoff;
z = z + zoff;
}
void scale(float xs, float ys, float zs){
x = x * xs;
y = y * ys;
z = z * zs;
}
// Rotation around the z-axis
void rotatez(float angle ){
float tempx = x * cos(angle) - y * sin(angle);
float tempy = y * cos(angle) + x * sin(angle);
x = tempx;
y = tempy;
}
//Rotation around the x-axis
void rotatex(float angle ){
float tempy = y * cos(angle) - z * sin(angle);
float tempz = z * cos(angle) + y * sin(angle);
y = tempy;
z = tempz;
}
//Rotation around the y-axis
void rotatey(float angle ){
float tempx = x * cos(angle) - z * sin(angle);
float tempz = z * cos(angle) + x * sin(angle);
x = tempx;
z = tempz;
}
int xP(float eye){
float t = 1.0/(1.0+((float) z / eye ));
int px = int( x * t);
return(px);
}
int yP(float eye){
float t = 1.0/(1.0+((float) z / eye ));
int py = int( y * t);
return(py);
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.