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//

[29287 byte] By [lightxxxa] at [2007-9-28 11:27:00]
# 1

/*

(purpose)

this class automatically double buffers i made it for easy graphing of functions

(use of this class)

thier are two abstracted methods that must be used in this class they are explained

overidedefaults(){} _

although this method maybe blank

it is a way to facilitate the overideing of the background and letter color

// bgcolor = new Color(15,15,15);

// gridcolor = new Color(115,15,15);

// lettercolor = new Color(130,210,240);

// showgrid = false; // showing the grid should also be turned on or off here

boolean showgrid this turns the grid on or off

new colors should be added in the run method but only once

you can alternatly put them outside these methods

to act global to the class

drawing(){}

this method is were you draw stuff normal commands such as these still apply

draw.drawString("",10,10);

draw.drawLine();

draw.fillRect(100,100,screen_width,200);

note the class is automatically doublebuffered and the mouse activity

is automatically set true if thier is any and false if thier is none

the following are reserved for the class and can be manipulated

int screen_width,screen_height,offsetX,offsetY

here offset x and y is 1/2 the screen width and height basically dead center of the applet

the following values are for moveing the grid around and stuff

int gridedgetop =70;int gridedgeleft = 70;// these values may be changed

int gridedgebottom = screen_height -100;int gridedgeright = screen_width -100;

int gridspaceing = 20;

below these hold the positions of the mouse and were its at and stuff

boolean mouseactivity = false;

int mouse_clicked_X, mouse_clicked_Y ;

int mouse_pressed_X, mouse_pressed_Y ;

int mouse_released_X, mouse_released_Y ;

int mouse_position_X, mouse_position_Y ;

*/

import java.awt.*;

import java.awt.event.*;

public class test2a extends AbstractGraph0_2b{

// VARIABLES

public final double PI = 3.1459;

public int X,Y,Z ;

public int X1,Y1,Z1,X2,Y2,Z2,X3,Y3,Z3,X4,Y4,Z4 ;

public int c1x =0,c1y =0,c1z =0, c2x =33,c2y =0,c2z = 0, c3x =66 ,c3y =0,c3z = 0, c4x =100 ,c4y =0,c4z = 0 ;

public int c5x =0,c5y =20,c5z = 0, c6x =33,c6y =20,c6z = 280, c7x =66 ,c7y =20,c7z = 0, c8x =100 ,c8y =20,c8z = 0 ;

public int c9x =0,c9y =40,c9z = 0, c10x =33,c10y =40,c10z = 0, c11x =66 ,c11y =40,c11z = 0, c12x =100 ,c12y =40,c12z = 0 ;

public int c13x =0,c13y =60,c13z = 0, c14x =33,c14y =60,c14z = 0, c15x =66 ,c15y =60,c15z = 0, c16x =100 ,c16y =60,c16z = 0 ;

int n = 0;int m =1;

double rotx =0,roty =0,rotz =0;

// REQUIRED METHODS __

public void overidefaults(){ gridedgetop =100;

addnewcontrolpoint(c1x,c1y,c1z,true,1.0);

addnewcontrolpoint(c2x,c2y,c2z,true,1.0);

addnewcontrolpoint(c3x,c3y,c3z,true,1.0);

addnewcontrolpoint(c4x,c4y,c4z,true,1.0);

addnewcontrolpoint(c5x,c5y,c5z,true,1.0);

addnewcontrolpoint(c6x,c6y,c6z,true,1.0);

addnewcontrolpoint(c7x,c7y,c7z,true,1.0);

addnewcontrolpoint(c8x,c8y,c8z,true,1.0);

addnewcontrolpoint(c9x,c9y,c9z,true,1.0);

addnewcontrolpoint(c10x,c10y,c10z,true,1.0);

addnewcontrolpoint(c11x,c11y,c11z,true,1.0);

addnewcontrolpoint(c12x,c12y,c12z,true,1.0);

addnewcontrolpoint(c13x,c13y,c13z,true,1.0);

addnewcontrolpoint(c14x,c14y,c14z,true,1.0);

addnewcontrolpoint(c15x,c15y,c15z,true,1.0);

addnewcontrolpoint(c16x,c16y,c16z,true,1.0);

}

public void drawing(){

rotx += .5;

//roty += .5;

rotz += .5;

if(rotx > 359){rotx =0;}if(roty > 359){roty =0;}if(rotz > 359){rotz =0;}

set_rotation(rotx,roty,rotz);

draw.setColor(Color.white);

draw.drawString(" this is a bicubic patch working on a B spline polynominal curve model " ,10,20);

draw.drawString(" " ,10,40);

draw.setColor(Color.white);

draw.drawString("xpos -offsetX = "+(mouse_position_X -offsetX) +" ypos -offsetY = "+(mouse_position_Y - offsetY) ,10,screen_height - 30);

patch(0,1,2,3,

4,5,6,7,

8,9,10,11,

12,13,14,15);

}

//__

public void patch(int A1,int B1,int C1,int D1,

int A2,int B2,int C2,int D2,

int A3,int B3,int C3,int D3,

int A4,int B4,int C4,int D4){

double s =0;

int switchval =0;

while(s < 1){

s += .01;

double a = s;

double b = 1 - s;

switchval ++;

if(switchval > 10){switchval = 0;}

if(switchval < 5){draw.setColor(Color.green);}

if(switchval > 4){draw.setColor(Color.red);}

X1 = (int)( getROTcontrolpointx(A1)*(b*b*b) + 3*getROTcontrolpointx(A2)*(b*b*a) + 3*getROTcontrolpointx(A3)*b*a*a + getROTcontrolpointx(A4)*(a*a*a) );

Y1 = (int)( getROTcontrolpointy(A1)*(b*b*b) + 3*getROTcontrolpointy(A2)*(b*b*a) + 3*getROTcontrolpointy(A3)*b*a*a + getROTcontrolpointy(A4)*(a*a*a) );

Z1 = (int)( getROTcontrolpointz(A1)*(b*b*b) + 3*getROTcontrolpointz(A2)*(b*b*a) + 3*getROTcontrolpointz(A3)*b*a*a + getROTcontrolpointz(A4)*(a*a*a) );

X2 = (int)( getROTcontrolpointx(B1)*(b*b*b) + 3*getROTcontrolpointx(B2)*(b*b*a) + 3*getROTcontrolpointx(B3)*b*a*a + getROTcontrolpointx(B4)*(a*a*a) );

Y2 = (int)( getROTcontrolpointy(B1)*(b*b*b) + 3*getROTcontrolpointy(B2)*(b*b*a) + 3*getROTcontrolpointy(B3)*b*a*a + getROTcontrolpointy(B4)*(a*a*a) );

Z2 = (int)( getROTcontrolpointz(B1)*(b*b*b) + 3*getROTcontrolpointz(B2)*(b*b*a) + 3*getROTcontrolpointz(B3)*b*a*a + getROTcontrolpointz(B4)*(a*a*a) );

X3 = (int)( getROTcontrolpointx(C1)*(b*b*b) + 3*getROTcontrolpointx(C2)*(b*b*a) + 3*getROTcontrolpointx(C3)*b*a*a + getROTcontrolpointx(C4)*(a*a*a) );

Y3 = (int)( getROTcontrolpointy(C1)*(b*b*b) + 3*getROTcontrolpointy(C2)*(b*b*a) + 3*getROTcontrolpointy(C3)*b*a*a + getROTcontrolpointy(C4)*(a*a*a) );

Z3 = (int)( getROTcontrolpointz(C1)*(b*b*b) + 3*getROTcontrolpointz(C2)*(b*b*a) + 3*getROTcontrolpointz(C3)*b*a*a + getROTcontrolpointz(C4)*(a*a*a) );

X4 = (int)( getROTcontrolpointx(D1)*(b*b*b) + 3*getROTcontrolpointx(D2)*(b*b*a) + 3*getROTcontrolpointx(D3)*b*a*a + getROTcontrolpointx(D4)*(a*a*a) );

Y4 = (int)( getROTcontrolpointy(D1)*(b*b*b) + 3*getROTcontrolpointy(D2)*(b*b*a) + 3*getROTcontrolpointy(D3)*b*a*a + getROTcontrolpointy(D4)*(a*a*a) );

Z4 = (int)( getROTcontrolpointz(D1)*(b*b*b) + 3*getROTcontrolpointz(D2)*(b*b*a) + 3*getROTcontrolpointz(D3)*b*a*a + getROTcontrolpointz(D4)*(a*a*a) );

curveb(X1,Y1,Z1,X2,Y2,Z2,X3,Y3,Z3,X4,Y4,Z4);

}//while

}//eof method

public void curveb(int ax,int ay,int az,int bx,int by,int bz,int cx,int cy,int cz,int dx,int dy,int dz){

double t =0;

while(t < 1){

t += .01;

double a = t;

double b = 1 - t;

X = (int)( ax*(b*b*b) + 3*bx*(b*b*a) + 3*cx*b*a*a + dx*(a*a*a) );

Y = (int)( ay*(b*b*b) + 3*by*(b*b*a) + 3*cy*b*a*a + dy*(a*a*a) );

Z = (int)( az*(b*b*b) + 3*bz*(b*b*a) + 3*cz*b*a*a + dz*(a*a*a) );

draw.drawRect(X + offsetX ,Y + offsetY ,1,1) ;

}//while

}//eof method

public void curve(int A,int B,int C,int D){

double t =0;

while(t < 1){

t += .01;

double a = t;

double b = 1 - t;

X = (int)( getcontrolpointx(A)*(b*b*b) + 3*getcontrolpointx(B)*(b*b*a) + 3*getcontrolpointx(C)*b*a*a + getcontrolpointx(D)*(a*a*a) );

Y = (int)( getcontrolpointy(A)*(b*b*b) + 3*getcontrolpointy(B)*(b*b*a) + 3*getcontrolpointy(C)*b*a*a + getcontrolpointy(D)*(a*a*a) );

draw.setColor(Color.red);

draw.drawRect(X + offsetX ,Y + offsetY ,2,2) ;

}//while

}//eof method

}// eof class

lightxxxa at 2007-7-12 2:01:55 > top of Java-index,Other Topics,Java Game Development...
# 2

<HTML>

<HEAD>

<TITLE>MyApplet Example1</TITLE>

</HEAD>

<BODY>

<H1>MyApplet</H1>

<HR>

<P>

<APPLET CODE="test2a.class" WIDTH="600" HEIGHT="400">

</APPLET>

</P>

<HR>

</BODY>

</HTML>

lightxxxa at 2007-7-12 2:01:55 > top of Java-index,Other Topics,Java Game Development...
# 3
1) use the [ c o d e ] tage2) so what does it actually *do*
shishthemoomina at 2007-7-12 2:01:55 > top of Java-index,Other Topics,Java Game Development...
# 4

it takes 16 points that you can click and move around on the fly

to alter a flat square to curve it into a cone or curved surface or whatever and it rotates in 3 dimentions on the fly

and use's a 2 dimentional polynominal algorithm

to create it in real time

but if you wanted you could make a polygon mesh out of it pretty easy

its kinda neet for anyone who wants to use matrixes for rotation

or for anyone who wants to see how polynominals can curve surfaces

into any shape you like.

the abstractgraph is just for the drawing

the other class has the algorithim

to simplify the principals involved

flat polygons are boring :( so

^__o__o

|t__o__o_

|i_X__point found from polynominals(S , T) you loop thru

|m__s and t

|e__to plot a buncha

|__ o__o_o__opoints

|S

|__o__oo__o control points you move around

|_

|__o__o_o__o

time T->

polynominal is simply A*t*t*t + B*t*t-(1-t) + C*t*(1-t)*(1-t) + D*(1-t)*(1-t)*(1-t)

lightxxxa at 2007-7-12 2:01:55 > top of Java-index,Other Topics,Java Game Development...
# 5

here i put it up on a site really quick i was bored and checking something

click on the blue points and drag them the points are acting kinda funny

so click and hold also this was just a experiment and the z coordinates cant change if anyone wants to see the code ill repost it with the code tags on this time.

http://www.geocities.com/donna_dulgo/Example1.html

lightxxxa at 2007-7-12 2:01:55 > top of Java-index,Other Topics,Java Game Development...