anyone wanna see code for a bicubic patch applet?
// theres 2 class and you need to make your own html file
// create the following two classes as applications and compile
// a bicubic patch is for 3d modeling
/*
authored by william motill
date nov 27, 2002
this versions simply going to allow me to do one thing and that is make control point vectors or
make realpoint vectors and have a switch for each to see if they should be clickable or moveable
*/
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.util.*;
import java.awt.image.*;
import java.util.StringTokenizer;
import java.io.*;
import java.net.URL;
import java.lang.String.*;
public abstract class AbstractGraph0_2b extends Applet implements Runnable,KeyListener,MouseListener,MouseMotionListener
{
//
// ABSTRACT METHODS ,THEY MUST BE IN THE CLASS THAT EXTENDS THIS CLASS
public abstract void overidefaults();
public abstract void drawing();
//
Thread thethread=null;
Image img;
Graphics draw ;
boolean startOut = true; // first time painting
Dimension scrdim ;
int screen_width,screen_height,offsetX,offsetY;
public boolean showgrid = true;
// default grid values
int framenumber;
int gridedgetop = 70,gridedgeleft = 70,gridedgebottom = -10,gridedgeright = -10,gridspaceing = 20;
Color bgcolor = new Color(15,15,15);
Color gridcolor = new Color(115,115,115);
Color lettercolor = new Color(130,210,240);
// points dimention size vars just change qa in the your instiated class in the defaultoveride method
int qa = 8, qb = (int)(.5*qa);
// mousevalues
boolean mousecontact = false; // technically this is a point value but its only activated by the mouse
boolean mouseactivity = false;
boolean mousepressed = false;
boolean mousereleased = false;
boolean mousedragged = false;
int mouse_clicked_X, mouse_clicked_Y, mouse_clicked_oX,mouse_clicked_oY ;
int mouse_pressed_X, mouse_pressed_Y, mouse_pressed_oX, mouse_pressed_oY ;
int mouse_released_X, mouse_released_Y, mouse_released_oX, mouse_released_oY ;
int mouse_position_X, mouse_position_Y, mouse_position_oX, mouse_position_oY ;
// make a set of arrays for realpoints and its corresponding boolean
public int pointstoelement ;private boolean isitthecontrolpoint = false;
private int nofrealpoints =0;
private int[] realpointx = new int[1],realpointy = new int[1],realpointz = new int[1];
private double[] realpointw = new double[1];
private boolean[] realpointmoveable = new boolean[1];
// make a set of arrays for controlpoints and its corresponding boolean
private int nofcontrolpoints =0;
private int[] controlpointx = new int[1],controlpointy = new int[1],controlpointz = new int[1];
private double[] controlpointw = new double[1];
private boolean[] controlpointmoveable = new boolean[1] ;
// dynamic resize methods
public final boolean[] addtoarraysize(boolean[] b,int add){boolean[] a = new boolean[b.length + add];System.arraycopy(b,0,a,0,b.length); return a;}
public final int[] addtoarraysize(int[] b,int add){int[] a = new int[b.length + add];System.arraycopy(b,0,a,0,b.length); return a;}
public final long[] addtoarraysize(long[] b,int add){long[] a = new long[b.length + add];System.arraycopy(b,0,a,0,b.length); return a;}
public final double[] addtoarraysize(double[] b,int add){double[] a = new double[b.length + add];System.arraycopy(b,0,a,0,b.length); return a;}
public final float[] addtoarraysize(float[] b,int add){float[] a = new float[b.length + add];System.arraycopy(b,0,a,0,b.length); return a;}
public final String[] addtoarraysize(String[] b,int add){String[] a = new String[b.length + add];System.arraycopy(b,0,a,0,b.length); return a;}
//__keyboaed and mouse input
public void keyReleased(KeyEvent e){}
public void keyPressed(KeyEvent e){}
public void keyTyped(KeyEvent e){
//keycheck =e.getKeyChar();
}
public void mouseClicked(MouseEvent me){mouse_clicked_X = me.getX();mouse_clicked_Y = me.getY();
mouse_clicked_oX = mouse_clicked_X + offsetX ;mouse_clicked_oY = mouse_clicked_Y + offsetY ;mouseactivity = true;
}
public void mouseEntered(MouseEvent me){}
public void mouseExited(MouseEvent me){}
public void mousePressed(MouseEvent me){mouse_pressed_X = me.getX();mouse_pressed_Y = me.getY();mouseactivity = true;mousepressed = true;
mouse_pressed_oX = me.getX() + offsetX ;mouse_pressed_oY = me.getY() + offsetY ;
}
public void mouseReleased(MouseEvent me){mouse_released_X = me.getX();mouse_released_Y = me.getY();mouseactivity = true;mousereleased = true;
mouse_released_oX = me.getX() + offsetX ;mouse_released_oY = me.getY() + offsetY ;
}
public void mouseDragged(MouseEvent me){mouse_position_X = me.getX();mouse_position_Y = me.getY();mouseactivity = true;mousedragged = true;;
mouse_position_oX = me.getX() + offsetX ;mouse_position_oY = me.getY() + offsetY ;
}
public void mouseMoved(MouseEvent me){mouse_position_X = me.getX();mouse_position_Y = me.getY();mouseactivity = true;
mouse_position_oX = me.getX() + offsetX ;mouse_position_oY = me.getY() + offsetY ;
}
//__
public void init() {
addMouseMotionListener(this);
addMouseListener(this);
addKeyListener(this);
scrdim = getSize();
img = createImage (scrdim.width ,scrdim.height);
draw = img.getGraphics();
overidefaults();
startOut = false ;
}
public void start(){
if(thethread==null){ // check if the thread running already
thethread=new Thread(this); // create a new thread and grab max priority
//thethread.setPriority(Thread.MIN_PRIORITY);
thethread.start(); // set the thread going
}
}
public void stop(){
if(thethread!=null){ // check if the thread is running
thethread=null; // stop the thread
}
}
public void update (Graphics g) {
paint(g);
}
synchronized public void paint(Graphics g){
g.drawImage(img,0,0,null ); // blit
notifyAll();
}
//__
synchronized public void run(){ //_
int loops =0;
// neccesary grid vars
screen_width =scrdim.width ; screen_height =scrdim.height ;
offsetX = (int)(screen_width *.5);offsetY = (int)(screen_height *.5);int offsetZ = 0;
framenumber =0;
gridedgebottom += screen_height ;// adjust to edge
gridedgeright += screen_width ;
while(true){ // do stuff **********************************************
// plz note every thing below is not neccessary only the call to drawing and below
// and the 3 lines below here which is basically the double buffering however if removed
// you may have to make adjustments in the users class to make it work right
draw.setColor(bgcolor);
draw.fillRect(0,0,scrdim.width,scrdim.height);
draw.setColor(gridcolor);
//__
drawing(); // __allow the user to draw stuff__
//__draw a graphtowork on maybe :)
if(showgrid == true){
draw.setColor(gridcolor);//draw.setColor(mycolorgray);
int speacialvarmover = 0;int speacialtrackmovervar =0;// for moveing the x lettering
for(int iy = offsetY;iy > gridedgetop;iy -=gridspaceing){
draw.drawLine(gridedgeleft+5,iy,gridedgeright,iy);draw.drawString("y "+(iy -offsetY),gridedgetop -20,iy);
}
for(int iy = offsetY;iy < gridedgebottom;iy +=gridspaceing){
draw.drawLine(gridedgeleft,iy,gridedgeright,iy);draw.drawString("y "+(iy -offsetY),gridedgetop -20,iy);
}
for(int ix = offsetX;ix > gridedgeleft;ix -=gridspaceing){
speacialtrackmovervar += gridspaceing;speacialvarmover -= 10;if(speacialtrackmovervar > 21){speacialtrackmovervar =0;speacialvarmover =0;}
draw.drawLine(ix,gridedgetop,ix,gridedgebottom);
draw.drawString(""+(ix -offsetX),ix,gridedgetop +speacialvarmover);
}
for(int ix = offsetX;ix < gridedgeright;ix +=gridspaceing){
//speacialvarmover += 10;if(speacialvarmover > 10){speacialvarmover =0;}
speacialtrackmovervar += gridspaceing;speacialvarmover -= 10;if(speacialtrackmovervar > 21){speacialtrackmovervar =0;speacialvarmover =0;}
draw.drawLine(ix,gridedgetop,ix,gridedgebottom);
draw.drawString(" "+(ix -offsetX),ix,gridedgetop +speacialvarmover);
}
// put in the crosshairs
draw.setColor(lettercolor);
draw.drawLine(offsetX,gridedgetop,offsetX,gridedgebottom);draw.drawLine(gridedgeleft,offsetY,gridedgeright,offsetY);
}
loops++;
draw.drawString(" Practical graph for points lines ect... by william motill frame # "+loops,10,screen_height - 12);
//auto move point or control point code
for(int i =0;i < realpointx.length;i ++){
if(nofrealpoints > 0){
draw.setColor(Color.red);draw.drawRect(getrealpointx(i) + offsetX -qb,getrealpointy(i) + offsetY -qb,qa,qa) ;
draw.setColor(Color.yellow);draw.drawString("P "+i,getrealpointx(i) + offsetX -qb,getrealpointy(i) + offsetY +qb+12) ;
}
if(getrealpointmoveable(i) == true){
draw.fillRect(getrealpointx(i) + offsetX -qb,getrealpointy(i) + offsetY -qb,qa,qa) ;
if(mousedragged == true || mousepressed == true){
if(mouse_position_X > getrealpointx(i) -qa + offsetX && mouse_position_X < getrealpointx(i) +qa + offsetX && mouse_position_Y > getrealpointy(i) -qa + offsetY && mouse_position_Y < getrealpointy(i) +qa + offsetY ){
isitthecontrolpoint = false;pointstoelement = (int)(i);draw.setColor(Color.white);draw.fillRect(getrealpointx(i) + offsetX -qb*2,getrealpointy(i) + offsetY -qb*2,qa*2,qa*2) ;
mousecontact = true;
}
}
}
}
for(int i =0;i < controlpointx.length;i ++){
if(nofcontrolpoints > 0){
draw.setColor(Color.magenta);draw.drawString("C "+i,getcontrolpointx(i) + offsetX -qb,getcontrolpointy(i) + offsetY +qb+12) ;
draw.setColor(Color.blue);draw.drawRect(getcontrolpointx(i) + offsetX -qb,getcontrolpointy(i) + offsetY -qb,qa,qa) ;
}
if(getcontrolpointmoveable(i) == true){
draw.fillRect(getcontrolpointx(i) + offsetX -qb,getcontrolpointy(i) + offsetY -qb,qa,qa) ;
if(mousedragged == true || mousepressed == true){
if(mouse_position_X > getcontrolpointx(i) -qa + offsetX && mouse_position_X < getcontrolpointx(i) +qa + offsetX && mouse_position_Y > getcontrolpointy(i) -qa + offsetY && mouse_position_Y < getcontrolpointy(i) +qa + offsetY ){
isitthecontrolpoint = true;pointstoelement = (int)(i);draw.setColor(Color.white);draw.drawRect(getcontrolpointx(i) + offsetX -qb*2,getcontrolpointy(i) + offsetY -qb*2,qa*2,qa*2) ;
mousecontact = true;
}
}
}
}
if(mousereleased == true){
if(mousecontact == true){
if(isitthecontrolpoint == false){ setrealpointx(pointstoelement,mouse_position_X -offsetX); setrealpointy(pointstoelement,mouse_position_Y -offsetY) ;}
if(isitthecontrolpoint == true ){ setcontrolpointx(pointstoelement,mouse_position_X -offsetX); setcontrolpointy(pointstoelement,mouse_position_Y -offsetY) ;}
mousecontact = false;
}
}
//__
//drawing(); // __allow the user to draw stuff__
mouseactivity = false;mousepressed = false ;
mousereleased = false;mousedragged = false;//mousecontact = false;
repaint(); // __call repaint __
try{ wait();} // __ synchronize the thread __
catch(InterruptedException e) { System.out.println( "sychronized exception is thrown" );}
} //endwhile
} // end run
//
// methods for points and control points
public void addnewcontrolpoint(int x,int y,int z,boolean moveable,double w){
if(nofcontrolpoints == 0){
controlpointx = new int[1];controlpointy = new int[1];controlpointz = new int[1];controlpointw = new double[1];controlpointmoveable = new boolean[1];
controlpointx[0] = x;controlpointy[0] = y;controlpointz[0] = z;
controlpointw[0] = w;controlpointmoveable[0] = moveable;
}
if(nofcontrolpoints > 0){
controlpointx = addtoarraysize(controlpointx,1);controlpointy = addtoarraysize(controlpointy,1);controlpointz = addtoarraysize(controlpointz,1);
controlpointw = addtoarraysize(controlpointw,1); controlpointmoveable = addtoarraysize(controlpointmoveable,1);
int cplength = controlpointx.length -1;
controlpointx[cplength] = x;controlpointy[cplength] = y;controlpointz[cplength] = z;
controlpointw[cplength] = w;controlpointmoveable[cplength] = moveable;
}
nofcontrolpoints =1;
}
public void addnewpoint(int x,int y,int z,boolean moveable,double w){
if(nofrealpoints == 0){
realpointx = new int[1];realpointy = new int[1];realpointz = new int[1];realpointw = new double[1];realpointmoveable = new boolean[1];
realpointx[0] = x;realpointy[0] = y;realpointz[0] = z;
realpointw[0] = w;realpointmoveable[0] = moveable;
}
if(nofrealpoints > 0){
realpointx = addtoarraysize(realpointx,1);realpointy = addtoarraysize(realpointy,1);realpointz = addtoarraysize(realpointz,1);
realpointw = addtoarraysize(realpointw,1); realpointmoveable = addtoarraysize(realpointmoveable,1);
int cplength = realpointx.length -1;
realpointx[cplength] = x;realpointy[cplength] = y;realpointz[cplength] = z;
realpointw[cplength] = w;realpointmoveable[cplength] = moveable;
}
nofrealpoints =1;
}
public int getnofrealpoints(){return realpointx.length;}
public int getnofcontrolpoints(){return controlpointx.length;}
public int getrealpointx(int n){return realpointx[n];}
public int getrealpointy(int n){return realpointy[n];}
public int getrealpointz(int n){return realpointz[n];}
public double getrealpointw(int n){return realpointw[n];}
public boolean getrealpointmoveable(int n){return realpointmoveable[n];}
public int getcontrolpointx(int n){return controlpointx[n];}
public int getcontrolpointy(int n){return controlpointy[n];}
public int getcontrolpointz(int n){return controlpointz[n];}
public double getcontrolpointw(int n){return controlpointw[n];}
public boolean getcontrolpointmoveable(int n){return controlpointmoveable[n];}
public void setrealpointx(int n,int v){realpointx[n] = v;}
public void setrealpointy(int n,int v){realpointy[n] = v;}
public void setrealpointz(int n,int v){realpointz[n] = v;}
public void setrealpointw(int n,double v){realpointw[n] = v;}
public void setrealpointmoveable(int n,boolean v){realpointmoveable[n] = v;}
public void setcontrolpointx(int n,int v){controlpointx[n] = v;}
public void setcontrolpointy(int n,int v){controlpointy[n] = v;}
public void setcontrolpointz(int n,int v){controlpointz[n] = v;}
public void setcontrolpointw(int n,double v){controlpointw[n] = v;}
public void setcontrolpointmoveable(int n,boolean v){controlpointmoveable[n] = v;}
// get rotated version
public int getROTrealpointx(int n){
setmaster_to_identity();//translate_master(tx,ty,tz);
rotate_master(mrx,mry,mrz);
multiply_vector(realpointx[n],realpointy[n],realpointz[n]);
return (int)(newx);
}
public int getROTrealpointy(int n){
setmaster_to_identity();//translate_master(tx,ty,tz);
rotate_master(mrx,mry,mrz);
multiply_vector(realpointx[n],realpointy[n],realpointz[n]);
return (int)(newy);
}
public int getROTrealpointz(int n){
setmaster_to_identity();//translate_master(tx,ty,tz);
rotate_master(mrx,mry,mrz);
multiply_vector(realpointx[n],realpointy[n],realpointz[n]);
return (int)(newz);
}
public double getROTrealpointw(int n){return realpointw[n];}
public boolean getROTrealpointmoveable(int n){return realpointmoveable[n];}
public int getROTcontrolpointx(int n){
setmaster_to_identity();//translate_master(tx,ty,tz);
rotate_master(mrx,mry,mrz);
multiply_vector(controlpointx[n],controlpointy[n],controlpointz[n]);
return (int)(newx);
}
public int getROTcontrolpointy(int n){
setmaster_to_identity();//translate_master(tx,ty,tz);
rotate_master(mrx,mry,mrz);
multiply_vector(controlpointx[n],controlpointy[n],controlpointz[n]);
return (int)(newy);
}
public int getROTcontrolpointz(int n){
setmaster_to_identity();//translate_master(tx,ty,tz);
rotate_master(mrx,mry,mrz);
multiply_vector(controlpointx[n],controlpointy[n],controlpointz[n]);
return (int)(newz);
}
public double getROTcontrolpointw(int n){return controlpointw[n];}
public boolean getROTcontrolpointmoveable(int n){return controlpointmoveable[n];}
//_matrix stuff__
// sin cos values
private static double mrx =0,mry = 0,mrz =0;
private static double newx =0,newy =0,newz =0;
private static double anglex =0,angley =0,anglez =0;
// a matrix
private static double
mb_00 =0, mb_01 =0, mb_02 =0, mb_03 =0,
mb_10 =0, mb_11 =0, mb_12 =0, mb_13 =0,
mb_20 =0, mb_21 =0, mb_22 =0, mb_23 =0,
mb_30 =0, mb_31 =0, mb_32 =0, mb_33 =0;
// b matrix
private static double
ma_00 =0, ma_01 =0, ma_02 =0, ma_03 =0,
ma_10 =0, ma_11 =0, ma_12 =0, ma_13 =0,
ma_20 =0, ma_21 =0, ma_22 =0, ma_23 =0,
ma_30 =0, ma_31 =0, ma_32 =0, ma_33 =0;
// master matrix
private static double
mm_00 =0, mm_01 =0, mm_02 =0, mm_03 =0,
mm_10 =0, mm_11 =0, mm_12 =0, mm_13 =0,
mm_20 =0, mm_21 =0, mm_22 =0, mm_23 =0,
mm_30 =0, mm_31 =0, mm_32 =0, mm_33 =0;
private static double sinus[];
private static double cosinus[];
private static boolean trig=false;
public static final double pi=3.1415926535;
private static double rad2scale=4096f/3.14159265f/2;
private static double pad=256*3.14159265;
public static final double deg2rad(double deg){return deg*0.0174532925194;}
public static final double rad2deg(double rad){return rad*57.295779514719;}
public static final double sin(double angle){if(!trig) buildTrig();return sinus[(int)((angle+pad)*rad2scale)&0xFFF];}
public static final double cos(double angle){if(!trig) buildTrig();return cosinus[(int)((angle+pad)*rad2scale)&0xFFF];}
private static void buildTrig(){
//System.out.println(">> Building Sin Cos table"),
sinus=new double[4096];cosinus=new double[4096];
for (int i=0;i<4096;i++){
sinus=(double)Math.sin((double)i/rad2scale);
cosinus=(double)Math.cos((double)i/rad2scale);
}
trig=true;
}
// these arent really used in this format only if i am going to
// sort of pre automate it and make the scale translation vals static
public static final void set_scale(double sx,double sy,double sz){
}
public static final void set_translation(){
}
public static final void set_rotation(double rx,double ry,double rz){
mrx = rx ; mry = ry ; mrz =rz ;
}
public static final void set_viewerrotation(){
}
public static final double get_X(){return newx ;}
public static final double get_Y(){return newy ;}
public static final double get_Z(){return newz ;}
// only real problem ive got is that everything should be standardized to double
// however actuall ploting takes place in reality in integer form of course
public static final void scale_master(double sx,double sy,double sz){
ma_00 = mm_00;ma_01 = mm_01;ma_02 = mm_02;ma_03 = mm_03;
ma_10 = mm_10;ma_11 = mm_11;ma_12 = mm_12;ma_13 = mm_13;
ma_20 = mm_20;ma_21 = mm_21;ma_22 = mm_22;ma_23 = mm_23;
ma_30 = mm_30;ma_31 = mm_31;ma_32 = mm_32;ma_33 = mm_33;
mb_00 =sx ; mb_01 =0; mb_02 =0; mb_03 =0;
mb_10 =0; mb_11 =sy ; mb_12 =0; mb_13 =0;
mb_20 =0; mb_21 =0; mb_22 =sz ; mb_23 =0;
mb_30 =0; mb_31 =0; mb_32 =0; mb_33 =1;
mm_00 = ma_00 * mb_00 + ma_01 * mb_10 + ma_02 * mb_20 + ma_03 * mb_30 ;
mm_01 = ma_00 * mb_01 + ma_01 * mb_11 + ma_02 * mb_21 + ma_03 * mb_31 ;
mm_02 = ma_00 * mb_02 + ma_01 * mb_12 + ma_02 * mb_22 + ma_03 * mb_32 ;
mm_03 = ma_00 * mb_03 + ma_01 * mb_13 + ma_02 * mb_23 + ma_03 * mb_33 ;
mm_10 = ma_10 * mb_00 + ma_11 * mb_10 + ma_12 * mb_20 + ma_13 * mb_30 ;
mm_11 = ma_10 * mb_01 + ma_11 * mb_11 + ma_12 * mb_21 + ma_13 * mb_31 ;
mm_12 = ma_10 * mb_02 + ma_11 * mb_12 + ma_12 * mb_22 + ma_13 * mb_32 ;
mm_13 = ma_10 * mb_03 + ma_11 * mb_13 + ma_12 * mb_23 + ma_13 * mb_33 ;
mm_20 = ma_20 * mb_00 + ma_21 * mb_10 + ma_22 * mb_20 + ma_23 * mb_30 ;
mm_21 = ma_20 * mb_01 + ma_21 * mb_11 + ma_22 * mb_21 + ma_23 * mb_31 ;
mm_22 = ma_20 * mb_02 + ma_21 * mb_12 + ma_22 * mb_22 + ma_23 * mb_32 ;
mm_23 = ma_20 * mb_03 + ma_21 * mb_13 + ma_22 * mb_23 + ma_23 * mb_33 ;
mm_30 = ma_30 * mb_00 + ma_31 * mb_10 + ma_32 * mb_20 + ma_33 * mb_30 ;
mm_31 = ma_30 * mb_01 + ma_31 * mb_11 + ma_32 * mb_21 + ma_33 * mb_31 ;
mm_32 = ma_30 * mb_02 + ma_31 * mb_12 + ma_32 * mb_22 + ma_33 * mb_32 ;
mm_33 = ma_30 * mb_03 + ma_31 * mb_13 + ma_32 * mb_23 + ma_33 * mb_33 ;
}
public static final void translate_master(double tx,double ty,double tz){
ma_00 = mm_00;ma_01 = mm_01;ma_02 = mm_02;ma_03 = mm_03;
ma_10 = mm_10;ma_11 = mm_11;ma_12 = mm_12;ma_13 = mm_13;
ma_20 = mm_20;ma_21 = mm_21;ma_22 = mm_22;ma_23 = mm_23;
ma_30 = mm_30;ma_31 = mm_31;ma_32 = mm_32;ma_33 = mm_33;
mb_00 =1; mb_01 =0; mb_02 =0; mb_03 =0;
mb_10 =0; mb_11 =1; mb_12 =0; mb_13 =0;
mb_20 =0; mb_21 =0; mb_22 =1; mb_23 =0;
mb_30 =tx ; mb_31 =ty ; mb_32 =tz ; mb_33 =1;
mm_00 = ma_00 * mb_00 + ma_01 * mb_10 + ma_02 * mb_20 + ma_03 * mb_30 ;
mm_01 = ma_00 * mb_01 + ma_01 * mb_11 + ma_02 * mb_21 + ma_03 * mb_31 ;
mm_02 = ma_00 * mb_02 + ma_01 * mb_12 + ma_02 * mb_22 + ma_03 * mb_32 ;
mm_03 = ma_00 * mb_03 + ma_01 * mb_13 + ma_02 * mb_23 + ma_03 * mb_33 ;
mm_10 = ma_10 * mb_00 + ma_11 * mb_10 + ma_12 * mb_20 + ma_13 * mb_30 ;
mm_11 = ma_10 * mb_01 + ma_11 * mb_11 + ma_12 * mb_21 + ma_13 * mb_31 ;
mm_12 = ma_10 * mb_02 + ma_11 * mb_12 + ma_12 * mb_22 + ma_13 * mb_32 ;
mm_13 = ma_10 * mb_03 + ma_11 * mb_13 + ma_12 * mb_23 + ma_13 * mb_33 ;
mm_20 = ma_20 * mb_00 + ma_21 * mb_10 + ma_22 * mb_20 + ma_23 * mb_30 ;
mm_21 = ma_20 * mb_01 + ma_21 * mb_11 + ma_22 * mb_21 + ma_23 * mb_31 ;
mm_22 = ma_20 * mb_02 + ma_21 * mb_12 + ma_22 * mb_22 + ma_23 * mb_32 ;
mm_23 = ma_20 * mb_03 + ma_21 * mb_13 + ma_22 * mb_23 + ma_23 * mb_33 ;
mm_30 = ma_30 * mb_00 + ma_31 * mb_10 + ma_32 * mb_20 + ma_33 * mb_30 ;
mm_31 = ma_30 * mb_01 + ma_31 * mb_11 + ma_32 * mb_21 + ma_33 * mb_31 ;
mm_32 = ma_30 * mb_02 + ma_31 * mb_12 + ma_32 * mb_22 + ma_33 * mb_32 ;
mm_33 = ma_30 * mb_03 + ma_31 * mb_13 + ma_32 * mb_23 + ma_33 * mb_33 ;
}
public static final void setmaster_to_identity(){
mm_00 =1; mm_01 =0; mm_02 =0; mm_03 =0;
mm_10 =0; mm_11 =1; mm_12 =0; mm_13 =0;
mm_20 =0; mm_21 =0; mm_22 =1; mm_23 =0;
mm_30 =0; mm_31 =0; mm_32 =0; mm_33 =1;
}
//im sure ill find a way to concancate this later
//this i suppose can also be used for a reverse angle rotation i think
public static final void rotate_master( double angx,double angy,double angz){
ma_00 = mm_00;ma_01 = mm_01;ma_02 = mm_02;ma_03 = mm_03;
ma_10 = mm_10;ma_11 = mm_11;ma_12 = mm_12;ma_13 = mm_13;
ma_20 = mm_20;ma_21 = mm_21;ma_22 = mm_22;ma_23 = mm_23;
ma_30 = mm_30;ma_31 = mm_31;ma_32 = mm_32;ma_33 = mm_33;
//rot x
double sn = sin(deg2rad(angx));
double cs = cos(deg2rad(angx));
mb_00 =1; mb_01 =0; mb_02 =0; mb_03 =0;
mb_10 =0; mb_11 =cs; mb_12 =sn; mb_13 =0;
mb_20 =0; mb_21 =-sn ; mb_22 =cs; mb_23 =0;
mb_30 =0; mb_31 =0; mb_32 =0; mb_33 =1;
mm_00 = ma_00 * mb_00 + ma_01 * mb_10 + ma_02 * mb_20 + ma_03 * mb_30 ;
mm_01 = ma_00 * mb_01 + ma_01 * mb_11 + ma_02 * mb_21 + ma_03 * mb_31 ;
mm_02 = ma_00 * mb_02 + ma_01 * mb_12 + ma_02 * mb_22 + ma_03 * mb_32 ;
mm_03 = ma_00 * mb_03 + ma_01 * mb_13 + ma_02 * mb_23 + ma_03 * mb_33 ;
mm_10 = ma_10 * mb_00 + ma_11 * mb_10 + ma_12 * mb_20 + ma_13 * mb_30 ;
mm_11 = ma_10 * mb_01 + ma_11 * mb_11 + ma_12 * mb_21 + ma_13 * mb_31 ;
mm_12 = ma_10 * mb_02 + ma_11 * mb_12 + ma_12 * mb_22 + ma_13 * mb_32 ;
mm_13 = ma_10 * mb_03 + ma_11 * mb_13 + ma_12 * mb_23 + ma_13 * mb_33 ;
mm_20 = ma_20 * mb_00 + ma_21 * mb_10 + ma_22 * mb_20 + ma_23 * mb_30 ;
mm_21 = ma_20 * mb_01 + ma_21 * mb_11 + ma_22 * mb_21 + ma_23 * mb_31 ;
mm_22 = ma_20 * mb_02 + ma_21 * mb_12 + ma_22 * mb_22 + ma_23 * mb_32 ;
mm_23 = ma_20 * mb_03 + ma_21 * mb_13 + ma_22 * mb_23 + ma_23 * mb_33 ;
mm_30 = ma_30 * mb_00 + ma_31 * mb_10 + ma_32 * mb_20 + ma_33 * mb_30 ;
mm_31 = ma_30 * mb_01 + ma_31 * mb_11 + ma_32 * mb_21 + ma_33 * mb_31 ;
mm_32 = ma_30 * mb_02 + ma_31 * mb_12 + ma_32 * mb_22 + ma_33 * mb_32 ;
mm_33 = ma_30 * mb_03 + ma_31 * mb_13 + ma_32 * mb_23 + ma_33 * mb_33 ;
//roty
sn = sin(deg2rad(angy));
cs = cos(deg2rad(angy));
mb_00 =cs ; mb_01 =0; mb_02 =-sn ; mb_03 =0;
mb_10 =0; mb_11 =1; mb_12 =0; mb_13 =0;
mb_20 =sn ; mb_21 =0; mb_22 =cs ; mb_23 =0;
mb_30 =0; mb_31 =0; mb_32 =0; mb_33 =1;
ma_00 = mm_00 * mb_00 + mm_01 * mb_10 + mm_02 * mb_20 + mm_03 * mb_30 ;
ma_01 = mm_00 * mb_01 + mm_01 * mb_11 + mm_02 * mb_21 + mm_03 * mb_31 ;
ma_02 = mm_00 * mb_02 + mm_01 * mb_12 + mm_02 * mb_22 + mm_03 * mb_32 ;
ma_03 = mm_00 * mb_03 + mm_01 * mb_13 + mm_02 * mb_23 + mm_03 * mb_33 ;
ma_10 = mm_10 * mb_00 + mm_11 * mb_10 + mm_12 * mb_20 + mm_13 * mb_30 ;
ma_11 = mm_10 * mb_01 + mm_11 * mb_11 + mm_12 * mb_21 + mm_13 * mb_31 ;
ma_12 = mm_10 * mb_02 + mm_11 * mb_12 + mm_12 * mb_22 + mm_13 * mb_32 ;
ma_13 = mm_10 * mb_03 + mm_11 * mb_13 + mm_12 * mb_23 + mm_13 * mb_33 ;
ma_20 = mm_20 * mb_00 + mm_21 * mb_10 + mm_22 * mb_20 + mm_23 * mb_30 ;
ma_21 = mm_20 * mb_01 + mm_21 * mb_11 + mm_22 * mb_21 + mm_23 * mb_31 ;
ma_22 = mm_20 * mb_02 + mm_21 * mb_12 + mm_22 * mb_22 + mm_23 * mb_32 ;
ma_23 = mm_20 * mb_03 + mm_21 * mb_13 + mm_22 * mb_23 + mm_23 * mb_33 ;
ma_30 = mm_30 * mb_00 + mm_31 * mb_10 + mm_32 * mb_20 + mm_33 * mb_30 ;
ma_31 = mm_30 * mb_01 + mm_31 * mb_11 + mm_32 * mb_21 + mm_33 * mb_31 ;
ma_32 = mm_30 * mb_02 + mm_31 * mb_12 + mm_32 * mb_22 + mm_33 * mb_32 ;
ma_33 = mm_30 * mb_03 + mm_31 * mb_13 + mm_32 * mb_23 + mm_33 * mb_33 ;
//rotz
sn = sin(deg2rad(angz));
cs = cos(deg2rad(angz));
mb_00 =cs ; mb_01 =sn ; mb_02 =0; mb_03 =0;
mb_10 =-sn ; mb_11 =cs ; mb_12 =0; mb_13 =0;
mb_20 =0; mb_21 =0; mb_22 =1; mb_23 =0;
mb_30 =0; mb_31 =0; mb_32 =0; mb_33 =1;
mm_00 = ma_00 * mb_00 + ma_01 * mb_10 + ma_02 * mb_20 + ma_03 * mb_30 ;
mm_01 = ma_00 * mb_01 + ma_01 * mb_11 + ma_02 * mb_21 + ma_03 * mb_31 ;
mm_02 = ma_00 * mb_02 + ma_01 * mb_12 + ma_02 * mb_22 + ma_03 * mb_32 ;
mm_03 = ma_00 * mb_03 + ma_01 * mb_13 + ma_02 * mb_23 + ma_03 * mb_33 ;
mm_10 = ma_10 * mb_00 + ma_11 * mb_10 + ma_12 * mb_20 + ma_13 * mb_30 ;
mm_11 = ma_10 * mb_01 + ma_11 * mb_11 + ma_12 * mb_21 + ma_13 * mb_31 ;
mm_12 = ma_10 * mb_02 + ma_11 * mb_12 + ma_12 * mb_22 + ma_13 * mb_32 ;
mm_13 = ma_10 * mb_03 + ma_11 * mb_13 + ma_12 * mb_23 + ma_13 * mb_33 ;
mm_20 = ma_20 * mb_00 + ma_21 * mb_10 + ma_22 * mb_20 + ma_23 * mb_30 ;
mm_21 = ma_20 * mb_01 + ma_21 * mb_11 + ma_22 * mb_21 + ma_23 * mb_31 ;
mm_22 = ma_20 * mb_02 + ma_21 * mb_12 + ma_22 * mb_22 + ma_23 * mb_32 ;
mm_23 = ma_20 * mb_03 + ma_21 * mb_13 + ma_22 * mb_23 + ma_23 * mb_33 ;
mm_30 = ma_30 * mb_00 + ma_31 * mb_10 + ma_32 * mb_20 + ma_33 * mb_30 ;
mm_31 = ma_30 * mb_01 + ma_31 * mb_11 + ma_32 * mb_21 + ma_33 * mb_31 ;
mm_32 = ma_30 * mb_02 + ma_31 * mb_12 + ma_32 * mb_22 + ma_33 * mb_32 ;
mm_33 = ma_30 * mb_03 + ma_31 * mb_13 + ma_32 * mb_23 + ma_33 * mb_33 ;
}
public static final void multiply_vector(double x ,double y ,double z ){
newx= x*mm_00+y*mm_10+z*mm_20+mm_30 ;
newy= x*mm_01+y*mm_11+z*mm_21+mm_31 ;
newz= x*mm_02+y*mm_12+z*mm_22+mm_32 ;
}
}//end class//

