/* Shin Yoshizawa: m5031126@u-aizu.ac.jp Thu Mar 16 18:35:13 JST 2000 */ import java.awt.*; import java.awt.event.*; import java.lang.*; import java.util.*; public class SplineManager extends Panel implements java.awt.event.MouseMotionListener,java.awt.event.MouseListener { Color tomato = new Color((float)(1.000000), (float)(0.388235),(float)(0.278431)); Color deeppink = new Color((float)(1.000000), (float)(0.078431),(float)(0.576471)); Color darkorange = new Color((float)(1.000000), (float)(0.549020),(float)(0.00000)); Color cornflowerblue = new Color((float)(0.392157), (float)(0.584314),(float)(0.929412)); Color teal = new Color((float)(0.000000),(float)(0.501961), (float)(0.501961)); Color blanchedalmond = new Color((float)(1.000000), (float)(0.921569),(float)(0.803922)); Color forestgreen = new Color((float)(0.133333),(float)(0.545098), (float)(0.133333)); Color mediumorchid = new Color((float)(0.729412),(float)(0.333333), (float)(0.827451)); Color darkcyan = new Color((float)(0.000000),(float)(0.545098), (float)(0.545098)); Color firebrick = new Color((float)(0.698039), (float)(0.133333),(float)(0.133333)); Color palevioletred = new Color((float)(0.858824),(float)(0.439216), (float)(0.576471)); Image double_buffer=null; Graphics dg=null; Graphics dummyg=null; Graphics mydg=null; Knot target; Knot backtarget; Knot LightSource; Knot OscPoint; Knot SkePoint; Knot NorPoint; Knot OffPoint; Dimension aread; Knot Center; DoubleVector Skeleton_Buffer_S[]; DoubleVector Skeleton_Buffer_E[]; int numberofSkeleton_Buffer; FamiliesofCurves fcurve; Vertex Skeleton_Buffer2[]; int numberofSkeleton_Buffer2; DoubleVector Voronoi_Buffer_S[]; DoubleVector Voronoi_Buffer_E[]; int numberofVoronoi_Buffer; double scale; Voronoi vgraph; LevelSet medialaxes; K_Driven medialKn; int virtualN=160; int sampling=1; int samplingvis=1; int curvev=1; int freescalesw=0; int freemovesw=0; int orsw=0; int norsw=0; int casw=0; int nsw=0; int csw=0; int tsw=0; int osw=0; int drawcontrolp=1; boolean oneoffsw= false; boolean onensw= false; int oneosw=0; int esw=0; int ofsw=0; int fnsw=0; int orcolorsw=0; int norcolorsw=0; int cacolorsw=0; int cvcolorsw=0; int evcolorsw=0; int oscolorsw=0; int oneoscolorsw=0; int ofcolorsw=0; int fncolorsw=0; int oneoffcolorsw=0; int onencolorsw=0; boolean skeleton1circle,skeleton1normal,skeleton1center,skeleton1movin, tracekminimalap,tracekminimacd1,tracekminimacd2,tracekminimacmap, contourmap,cdriven1,cdriven2,laplace,skeleton1,skeleton2,voronoid; boolean Rating[] = new boolean[16]; Cursor defc; /* move osc */ int oscdvsw=0; double paramosc=0.0; /* move ske */ int skedvsw=0; int paramske=0; /* move offset */ double paramoff=0.0; int offdvsw=0; double offparam=0.0; /* move nor */ double paramnor=0.0; int nordvsw=0; Dimension dd; B_SplineClosed mycurve; Knot NULL = new Knot(0.0,0.0,0); Scrollbar scrX,scrY; public SplineManager(int width,int height,B_SplineClosed bscc){ dd = new Dimension(); dd.width = width; dd.height = height; mycurve = bscc; target = NULL; backtarget = NULL; OscPoint = new Knot(0.0,0.0); OscPoint.error = 1; SkePoint = new Knot(0.0,0.0); SkePoint.error = 1; NorPoint = new Knot(0.0,0.0); NorPoint.error = 1; OffPoint = new Knot(0.0,0.0); OffPoint.error = 1; Center = new Knot(0,0); medialaxes = new LevelSet(); medialKn = new K_Driven(); vgraph=new Voronoi(2000); Skeleton_Buffer_S=null; Skeleton_Buffer_E=null; numberofSkeleton_Buffer=0; Skeleton_Buffer2=null; numberofSkeleton_Buffer2=0; numberofVoronoi_Buffer=0; Voronoi_Buffer_S=null; Voronoi_Buffer_E=null; for(int i=0;i<14;i++){ Rating[i] = false; } Rating[14] = true; Rating[15] = true; skeleton1movin = false; skeleton1circle = false; skeleton1normal = false; skeleton1center = false; tracekminimalap = false; tracekminimacd1 = false; tracekminimacd2 = false; tracekminimacmap = false; contourmap = false; cdriven1 = false; cdriven2 = false; laplace = false; skeleton1 = false; skeleton2 = false; voronoid = false; fcurve = new FamiliesofCurves(); scale = 1.0; this.setForeground(Color.black); this.setBackground(Color.white); this.addMouseListener(this); this.addMouseMotionListener(this); defc = new Cursor(Cursor.DEFAULT_CURSOR); this.setSize(width,height); aread = this.getSize(); aread.width = aread.width + 10; aread.height = aread.height + 10; double nx = ((400 -5)/(mycurve.scale)); double ny = ((aread.height - (200 +5))/(mycurve.scale)); LightSource = new Knot(nx,ny); LightSource.error = 1; } public void setEvolutionP(int di11,int di12,int di21,int di22, int di31,int di32,int di41,int di42,double dvC, double dvD,double dvLE,double dDis){ fcurve.setInit(di11,di12,di21,di22,di31,di32,di41,di42,dvC,dvD,dvLE,dDis); } public void clearimage(B_SplineClosed bscc) { Skeleton_Buffer_S=null; Skeleton_Buffer_E=null; numberofSkeleton_Buffer=0; Skeleton_Buffer2=null; numberofSkeleton_Buffer2=0; fcurve.clear(); fcurve = new FamiliesofCurves(); numberofVoronoi_Buffer=0; Voronoi_Buffer_S=null; Voronoi_Buffer_E=null; oneoffsw= false; onensw= false; drawcontrolp=1; curvev=1;sampling=1;virtualN=160;samplingvis=1; freemovesw=0; nsw=0; csw=0; tsw=0; osw=0; oneosw=0; esw=0; oscdvsw=0; skedvsw=0; offdvsw=0; nordvsw=0; ofsw=0; fnsw=0; casw=0; orsw=0; norsw=0; orcolorsw=0; norcolorsw=0; cacolorsw=0; cvcolorsw=0; evcolorsw=0; oscolorsw=0; ofcolorsw=0; fncolorsw=0; freescalesw=0; oneoscolorsw=0; oneoffcolorsw=0; onencolorsw=0; paramosc=0.0; paramske=0; paramoff=0.0; offparam=0.0; paramnor=0.0; skeleton1movin = false; skeleton1circle = false; skeleton1normal = false; skeleton1center = false; tracekminimalap = false; tracekminimacd1 = false; tracekminimacd2 = false; tracekminimacmap = false; contourmap = false; cdriven1 = false; cdriven2 = false; laplace = false; skeleton1 = false; skeleton2 = false; voronoid = false; medialaxes = new LevelSet(); vgraph = new Voronoi(200); target = NULL; backtarget = NULL; dg.setColor(Color.white); dg.fillRect(0,0,dd.width,dd.height); mycurve = bscc; double nx = ((400 -5)/(mycurve.scale)); double ny = ((aread.height - (200 +5))/(mycurve.scale)); LightSource = new Knot(nx,ny); LightSource.error = 1; OscPoint = new Knot(0.0,0.0); OscPoint.error = 1; SkePoint = new Knot(0.0,0.0); SkePoint.error = 1; NorPoint = new Knot(0.0,0.0); NorPoint.error = 1; OffPoint = new Knot(0.0,0.0); OffPoint.error = 1; Center = new Knot(0,0); scale = 1.0; this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); defc = new Cursor(Cursor.DEFAULT_CURSOR); aread = this.getSize(); this.repaint(); } public void Rescale(){ /* initial scale */ mycurve.scale = mycurve.iscale; this.repaint(); } public void setScrollbar(Scrollbar dscrX,Scrollbar dscrY){ scrX = dscrX; scrY = dscrY; } public void CenterMove(){ Center = new Knot(0,0); this.repaint(); } public void FreePick(){ freescalesw=0; freemovesw=0; this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } public void FreeScale(){ freescalesw=1; freemovesw=0; this.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); } public void FreeMove(){ freemovesw=1; freescalesw=0; this.setCursor(new Cursor(Cursor.MOVE_CURSOR)); } public void newboxcbSelect(boolean s1,boolean s2,boolean s3,boolean s4, boolean s5,boolean s6,boolean s7,boolean s8){ if(s1){skeleton1circle=true;}else{skeleton1circle=false;} if(s2){skeleton1normal=true;}else{skeleton1normal=false;} if(s3){skeleton1center=true;}else{skeleton1center=false;} if(s4){tracekminimalap=true;}else{tracekminimalap=false;} if(s5){tracekminimacd1=true;}else{tracekminimacd1=false;} if(s6){tracekminimacd2=true;}else{tracekminimacd2=false;} if(s7){tracekminimacmap=true;}else{tracekminimacmap=false;} if(s8){skeleton1movin=true;}else{skeleton1movin=false;} repaint(); } public void setRating(Vector drating){ for(int i=0;i<16;i++){ Rating[i] = ((Checkbox)drating.elementAt(i)).getState(); } if(Rating[4] && (oneosw==1)){ paramosc = (double)((int)(paramosc)); } if(Rating[8] && onensw){ paramnor = (double)((int)(paramnor)); } if(Rating[13] && skeleton1movin){ paramske = 0; } this.renewalpaint(); } public void ColorSelect(boolean s1,boolean s2,boolean s3,boolean s4, boolean s5,boolean s6,boolean s7,boolean s8, boolean s9,boolean s10,boolean s11,boolean s12, boolean s13,boolean s14,boolean s15){ if(s1){cvcolorsw=1;}else{cvcolorsw=0;} if(s2){evcolorsw=1;}else{evcolorsw=0;} if(s3){oscolorsw=1;}else{oscolorsw=0;} if(s4){ofcolorsw=1;}else{ofcolorsw=0;} if(s5){fncolorsw=1;}else{fncolorsw=0;} if(s6){oneoscolorsw=1;}else{oneoscolorsw=0;} if(s7){cacolorsw=1;}else{cacolorsw=0;} if(s8){orcolorsw=1;}else{orcolorsw=0;} if(s9){norcolorsw=1;}else{norcolorsw=0;} if(s10){onencolorsw=1;}else{onencolorsw=0;} if(s11){oneoffcolorsw=1;}else{oneoffcolorsw=0;} if(s12){drawcontrolp=1;}else{drawcontrolp=0;} if(s13){curvev=1;}else{curvev=0;} int dummysampling = sampling; if(s14){sampling=1;}else{sampling=0;} if(s15){samplingvis=1;}else{samplingvis=0;} if(dummysampling==sampling){ this.repaint(); }else{ this.renewalpaint(); } } public void causticVisible(){ if((casw==0)&&(mycurve.numberofpoint>=3)){ casw=1; }else{ casw=0; } this.repaint(); } public void curvatureVisible(){ if((csw==0)&&(mycurve.numberofpoint>=3)){ csw=1; }else{ csw=0; } this.repaint(); } public void normalVisible(){ if((nsw==0)&&(mycurve.numberofpoint>=3)){ nsw=1; }else{ nsw=0; } this.repaint(); } public void tangentVisible(){ if((tsw==0)&&(mycurve.numberofpoint>=3)){ tsw=1; }else{ tsw=0; } this.repaint(); } public void orthotomicVisible(){ if((orsw==0)&&(mycurve.numberofpoint>=3)){ orsw=1; }else{ orsw=0; } this.repaint(); } public void normalorVisible(){ if((norsw==0)&&(mycurve.numberofpoint>=3)){ norsw=1; }else{ norsw=0; } this.repaint(); } public void evoluteVisible(){ if((esw==0)&&(mycurve.numberofpoint>=3)){ esw=1; }else{ esw=0; } this.repaint(); } public void onenormalVisible(){ if((!onensw)&&(mycurve.numberofpoint>=3)){ onensw=true; DoubleVector dnow = mycurve.getPoint(0.0); NorPoint = new Knot(dnow.x,dnow.y); NorPoint.error = 1; paramnor=0.0; }else{ onensw=false; } this.repaint(); } public void oneoffVisible(){ if((!oneoffsw)&&(mycurve.numberofpoint>=3)){ oneoffsw=true; DoubleVector dnow = mycurve.getPoint(0.0); OffPoint = new Knot(dnow.x,dnow.y); OffPoint.error = 1; paramoff=0.0; offparam=0.0; }else{ oneoffsw=false; } this.repaint(); } public void oneosculatingVisible(){ if((oneosw==0)&&(mycurve.numberofpoint>=3)){ oneosw=1; DoubleVector dnow = mycurve.getPoint(0.0); OscPoint = new Knot(dnow.x,dnow.y); OscPoint.error = 1; paramosc=0.0; }else{ oneosw=0; } this.repaint(); } public void osculatingVisible(){ if((osw==0)&&(mycurve.numberofpoint>=3)){ osw=1; }else{ osw=0; } this.repaint(); } public void offsetVisible(){ if((ofsw==0)&&(mycurve.numberofpoint>=3)){ ofsw=1; }else{ ofsw=0; } this.repaint(); } public void contourmapVisible(){ if(!contourmap){ contourmap = true; double deforePARAM = mycurve.PARAM; if(sampling==1){ mycurve.changePARAM(0.05); } makeContour(); mycurve.changePARAM(deforePARAM); }else{ contourmap = false; } this.repaint(); } public void cdriven1Visible(){ if(!cdriven1){ cdriven1 = true; double deforePARAM = mycurve.PARAM; if(sampling==1){ mycurve.changePARAM(0.05); } makeCDriven(); mycurve.changePARAM(deforePARAM); }else{ cdriven1 = false; } this.repaint(); } public void cdriven2Visible(){ if(!cdriven2){ cdriven2 = true; double deforePARAM = mycurve.PARAM; if(sampling==1){ mycurve.changePARAM(0.05); } makeCDriven2(); mycurve.changePARAM(deforePARAM); }else{ cdriven2 = false; } this.repaint(); } public void laplaceVisible(){ if(!laplace){ laplace = true; double deforePARAM = mycurve.PARAM; if(sampling==1){ mycurve.changePARAM(0.05); } makeLaplace(); mycurve.changePARAM(deforePARAM); }else{ laplace = false; } this.repaint(); } public void skeleton1Visible(){ if(!skeleton1){ skeleton1 = true; double deforePARAM = mycurve.PARAM; if(sampling==1){ mycurve.changePARAM(0.05); } makeSkeleton1(); mycurve.changePARAM(deforePARAM); DoubleVector dnow = mycurve.getPoint(0.0); SkePoint = new Knot(dnow.x,dnow.y); SkePoint.error = 1; paramske=0; }else{ skeleton1 = false; } this.repaint(); } public void skeleton2Visible(){ if(!skeleton2){ skeleton2 = true; makeSkeleton2(); }else{ skeleton2 = false; } this.repaint(); } public void voronoidVisible(){ if(!voronoid){ voronoid = true; makeVoronoi(); }else{ voronoid = false; } this.repaint(); } public void familyNVisible(){ if((fnsw==0)&&(mycurve.numberofpoint>=3)){ fnsw=1; }else{ fnsw=0; } this.repaint(); } public void changeParam(int dv){ double dp; virtualN = dv; dp = (((double)(mycurve.numberofpoint))/((double)(dv))); //System.out.println("dv = "+dv); //System.out.println("dp = "+dp); mycurve.changePARAM(dp); if(skeleton1 && skeleton1movin){ paramske = 0; } this.renewalpaint(); } public void moveCenter(int dx,int dy){ Center.x = dx; Center.y = dy; this.repaint(); } public void doLayout(){ System.out.println("doLayout"); Image img = double_buffer; double_buffer = createImage(dd.width,dd.height); if (double_buffer != null) dg = double_buffer.getGraphics(); if (img != null) dg.drawImage(img, 0, 0, null); } public void drawnormal(Graphics myg){ myg.setColor(darkorange); DoubleVector dnow,dumnow,dumdum,da1,da2; Knot now; double dx,dy; Arrow mya; for(double t = 0.0; t<=((double)(mycurve.numberofpoint));t+=mycurve.PARAM){ dnow = mycurve.getPoint(t); now = new Knot(dnow.x,dnow.y); now.normal = mycurve.getNormal(t); dumnow = Reparametrization(now.x,now.y); dx = 0.7*(now.normal).x + now.x; dy = 0.7*(now.normal).y + now.y; dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x), (int)(dumdum.y)); da1 = new DoubleVector((int)(dumnow.x),(int)(dumnow.y)); da2 = new DoubleVector((int)(dumdum.x),(int)(dumdum.y)); mya = new Arrow(da1,da2); myg.fillPolygon(mya); } myg.setColor(Color.black); } public void drawenvelop(Graphics myg) { myg.setColor(darkorange); DoubleVector dnow,dumnow,dumdum; double dx,dy; Knot now; double length = (10.0 + 1000.0/mycurve.scale); for(double t = 0.0; t<=((double)(mycurve.numberofpoint));t+=mycurve.PARAM){ dnow = mycurve.getPoint(t); now = new Knot(dnow.x,dnow.y); now.normal = mycurve.getNormal(t); dx = (now.x + length*now.normal.x); dy = (now.y + length*now.normal.y); dumnow = Reparametrization(dx,dy); dx = (now.x - length*now.normal.x); dy = (now.y - length*now.normal.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x), (int)(dumdum.y)); } myg.setColor(Color.black); } public void drawColorenvelop(Graphics myg) { float h = ((float)(0.0)); DoubleVector dnow,dumnow,dumdum; double dx,dy; Knot now; double length = (10.0 + 1000.0/mycurve.scale); for(double t = 0.0; t<=((double)(mycurve.numberofpoint));t+=mycurve.PARAM){ h = (float)(t/((float)(mycurve.numberofpoint))); myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); dnow = mycurve.getPoint(t); now = new Knot(dnow.x,dnow.y); now.normal = mycurve.getNormal(t); dx = (now.x + length*now.normal.x); dy = (now.y + length*now.normal.y); dumnow = Reparametrization(dx,dy); dx = (now.x - length*now.normal.x); dy = (now.y - length*now.normal.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x), (int)(dumdum.y)); } myg.setColor(Color.black); } public void drawColoroffset(Graphics myg) { myg.setColor(cornflowerblue); float h = ((float)(0.0)); DoubleVector dnow,dnext,dumnow,dumdum; Knot now,next; double dx,dy; for(double t = 0.0; t<=((double)((mycurve).numberofpoint)); t+=mycurve.PARAM){ h = (float)(t/((float)(mycurve.numberofpoint))); myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); dnow = mycurve.getPoint(t); dnext = mycurve.getPoint((t+mycurve.PARAM)); now = new Knot(dnow.x,dnow.y); next = new Knot(dnext.x,dnext.y); next.normal = mycurve.getNormal((t+mycurve.PARAM)); now.normal = mycurve.getNormal(t); now.k = mycurve.getK(t); next.k = mycurve.getK((t+mycurve.PARAM)); for(double i=-2000.0/mycurve.scale; i<=4000.0/mycurve.scale;i = i + 100.0/mycurve.scale){ dx = (now.x - (0.2*i)*(now.normal).x); dy = (now.y - (0.2*i)*(now.normal).y); dumnow = Reparametrization(dx,dy); dx = (next.x - (0.2*i)*(next.normal).x); dy = (next.y - (0.2*i)*(next.normal).y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } } myg.setColor(Color.black); } public void drawoffset(Graphics myg) { myg.setColor(cornflowerblue); DoubleVector dnow,dnext,dumnow,dumdum; Knot now,next; double dx,dy; for(double t = 0.0; t<=((double)((mycurve).numberofpoint)); t+=mycurve.PARAM){ dnow = mycurve.getPoint(t); dnext = mycurve.getPoint((t+mycurve.PARAM)); now = new Knot(dnow.x,dnow.y); next = new Knot(dnext.x,dnext.y); next.normal = mycurve.getNormal((t+mycurve.PARAM)); now.normal = mycurve.getNormal(t); now.k = mycurve.getK(t); next.k = mycurve.getK((t+mycurve.PARAM)); for(double i=-2000.0/mycurve.scale; i<=4000.0/mycurve.scale;i = i + 100.0/mycurve.scale){ dx = (now.x - (0.2*i)*(now.normal).x); dy = (now.y - (0.2*i)*(now.normal).y); dumnow = Reparametrization(dx,dy); dx = (next.x - (0.2*i)*(next.normal).x); dy = (next.y - (0.2*i)*(next.normal).y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } } myg.setColor(Color.black); } public void drawColoroneoffset(Graphics myg){ myg.setColor(darkorange); DoubleVector doff = mycurve.getPoint(paramoff); OffPoint.x = doff.x; OffPoint.y = doff.y; DoubleVector dumoff = Reparametrization(OffPoint.x,OffPoint.y); myg.fillArc((int)(dumoff.x - 0.1*mycurve.scale), (int)(dumoff.y - 0.1*mycurve.scale), (int)(0.2*mycurve.scale),(int)(0.2*mycurve.scale),0,360); float h = ((float)(0.0)); double length = (10.0 + 1000.0/mycurve.scale); DoubleVector dnow,dnext,dumnow,dumdum; Knot now,next; double dx,dy; for(double t = 0.0; t<=((double)((mycurve).numberofpoint)); t+=mycurve.PARAM){ h = (float)(t/((float)(mycurve.numberofpoint))); myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); dnow = mycurve.getPoint(t); dnext = mycurve.getPoint((t+mycurve.PARAM)); now = new Knot(dnow.x,dnow.y); next = new Knot(dnext.x,dnext.y); next.normal = mycurve.getNormal((t+mycurve.PARAM)); now.normal = mycurve.getNormal(t); now.k = mycurve.getK(t); next.k = mycurve.getK((t+mycurve.PARAM)); dx = (now.x - (offparam/100.0)*(now.normal).x); dy = (now.y - (offparam/100.0)*(now.normal).y); dumnow = Reparametrization(dx,dy); dx = (next.x - (offparam/100.0)*(next.normal).x); dy = (next.y - (offparam/100.0)*(next.normal).y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } myg.setColor(Color.black); } public void drawoneoffset(Graphics myg){ myg.setColor(darkorange); DoubleVector doff = mycurve.getPoint(paramoff); OffPoint.x = doff.x; OffPoint.y = doff.y; DoubleVector dumoff = Reparametrization(OffPoint.x,OffPoint.y); myg.fillArc((int)(dumoff.x - 0.1*mycurve.scale), (int)(dumoff.y - 0.1*mycurve.scale), (int)(0.2*mycurve.scale),(int)(0.2*mycurve.scale),0,360); double length = (10.0 + 1000.0/mycurve.scale); DoubleVector dnow,dnext,dumnow,dumdum; Knot now,next; double dx,dy; for(double t = 0.0; t<=((double)((mycurve).numberofpoint)); t+=mycurve.PARAM){ dnow = mycurve.getPoint(t); dnext = mycurve.getPoint((t+mycurve.PARAM)); now = new Knot(dnow.x,dnow.y); next = new Knot(dnext.x,dnext.y); next.normal = mycurve.getNormal((t+mycurve.PARAM)); now.normal = mycurve.getNormal(t); now.k = mycurve.getK(t); next.k = mycurve.getK((t+mycurve.PARAM)); dx = (now.x - (offparam/100.0)*(now.normal).x); dy = (now.y - (offparam/100.0)*(now.normal).y); dumnow = Reparametrization(dx,dy); dx = (next.x - (offparam/100.0)*(next.normal).x); dy = (next.y - (offparam/100.0)*(next.normal).y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } myg.setColor(Color.black); } public void drawonenormal(Graphics myg){ myg.setColor(cornflowerblue); DoubleVector dnor = mycurve.getPoint(paramnor); NorPoint.x = dnor.x; NorPoint.y = dnor.y; DoubleVector dumnor = Reparametrization(NorPoint.x,NorPoint.y); myg.fillArc((int)(dumnor.x - 0.1*mycurve.scale), (int)(dumnor.y - 0.1*mycurve.scale), (int)(0.2*mycurve.scale),(int)(0.2*mycurve.scale),0,360); double length = (10.0 + 1000.0/mycurve.scale); NorPoint.normal = mycurve.getNormal(paramnor); double dx,dy; dx = (NorPoint.x + length*(NorPoint.normal).x); dy = (NorPoint.y + length*(NorPoint.normal).y); DoubleVector dumnow = Reparametrization(dx,dy); dx = (NorPoint.x - length*(NorPoint.normal).x); dy = (NorPoint.y - length*(NorPoint.normal).y); DoubleVector dumdum = Reparametrization(dx,dy); myg.setColor(mediumorchid); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); myg.setColor(Color.black); } public void drawColoronenormal(Graphics myg){ float h = ((float)(0.0)); h = (float)(paramnor/((float)(mycurve.numberofpoint))); myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); DoubleVector dnor = mycurve.getPoint(paramnor); NorPoint.x = dnor.x; NorPoint.y = dnor.y; DoubleVector dumnor = Reparametrization(NorPoint.x,NorPoint.y); myg.fillArc((int)(dumnor.x - 0.1*mycurve.scale), (int)(dumnor.y - 0.1*mycurve.scale), (int)(0.2*mycurve.scale),(int)(0.2*mycurve.scale),0,360); double length = (10.0 + 1000.0/mycurve.scale); NorPoint.normal = mycurve.getNormal(paramnor); double dx,dy; dx = (NorPoint.x + length*(NorPoint.normal).x); dy = (NorPoint.y + length*(NorPoint.normal).y); DoubleVector dumnow = Reparametrization(dx,dy); dx = (NorPoint.x - length*(NorPoint.normal).x); dy = (NorPoint.y - length*(NorPoint.normal).y); DoubleVector dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); myg.setColor(Color.black); } public void drawoneosculating(Graphics myg){ myg.setColor(tomato); DoubleVector dosc = mycurve.getPoint(paramosc); OscPoint.x = dosc.x; OscPoint.y = dosc.y; DoubleVector dumosc = Reparametrization(OscPoint.x,OscPoint.y); myg.fillArc((int)(dumosc.x - 0.1*mycurve.scale), (int)(dumosc.y - 0.1*mycurve.scale), (int)(0.2*mycurve.scale),(int)(0.2*mycurve.scale),0,360); myg.setColor(teal); double dx,dy; OscPoint.normal = mycurve.getNormal(paramosc); OscPoint.k = mycurve.getK(paramosc); double length = (10.0 + 1000.0/mycurve.scale); if(Math.abs(OscPoint.k)<=0.00000000001){ /* radius is infinity */ DoubleVector doscinfinityT = mycurve.getTangent(paramosc); dx = (dosc.x + length*(doscinfinityT).x); dy = (dosc.y + length*(doscinfinityT).y); DoubleVector dumnow = Reparametrization(dx,dy); dx = (dosc.x - length*(doscinfinityT).x); dy = (dosc.y - length*(doscinfinityT).y); dumosc = Reparametrization(dx,dy); myg.drawLine((int)(dumosc.x),(int)(dumosc.y), (int)(dumnow.x),(int)(dumnow.y)); myg.setColor(Color.black); }else{ double dummy = (1.0/OscPoint.k); dx = (OscPoint.x + dummy*(OscPoint.normal).x); dy = (OscPoint.y + dummy*(OscPoint.normal).y); DoubleVector dumnow = Reparametrization(dx,dy); double dummyradius = mycurve.scale*Math.abs(dummy); myg.drawArc((int)(dumnow.x - dummyradius), (int)(dumnow.y - dummyradius), (int)(2.0*dummyradius), (int)(2.0*dummyradius),0,360); myg.setColor(Color.black); myg.drawLine((int)(dumosc.x),(int)(dumosc.y), (int)(dumnow.x),(int)(dumnow.y)); } } public void drawColoroneosculating(Graphics myg){ float h = ((float)(0.0)); h = (float)(paramosc/((float)(mycurve.numberofpoint))); myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); DoubleVector dosc = mycurve.getPoint(paramosc); OscPoint.x = dosc.x; OscPoint.y = dosc.y; DoubleVector dumosc = Reparametrization(OscPoint.x,OscPoint.y); myg.fillArc((int)(dumosc.x - 0.1*mycurve.scale), (int)(dumosc.y - 0.1*mycurve.scale), (int)(0.2*mycurve.scale),(int)(0.2*mycurve.scale),0,360); double dx,dy; OscPoint.normal = mycurve.getNormal(paramosc); OscPoint.k = mycurve.getK(paramosc); double length = (10.0 + 1000.0/mycurve.scale); if(Math.abs(OscPoint.k)<=0.00000000001){ /* radius is infinity */ DoubleVector doscinfinityT = mycurve.getTangent(paramosc); dx = (dosc.x + length*(doscinfinityT).x); dy = (dosc.y + length*(doscinfinityT).y); DoubleVector dumnow = Reparametrization(dx,dy); dx = (dosc.x - length*(doscinfinityT).x); dy = (dosc.y - length*(doscinfinityT).y); dumosc = Reparametrization(dx,dy); myg.drawLine((int)(dumosc.x),(int)(dumosc.y), (int)(dumnow.x),(int)(dumnow.y)); myg.setColor(Color.black); }else{ double dummy = (1.0/OscPoint.k); dx = (OscPoint.x + dummy*(OscPoint.normal).x); dy = (OscPoint.y + dummy*(OscPoint.normal).y); DoubleVector dumnow = Reparametrization(dx,dy); double dummyradius = mycurve.scale*Math.abs(dummy); myg.drawArc((int)(dumnow.x - dummyradius), (int)(dumnow.y - dummyradius), (int)(2.0*dummyradius), (int)(2.0*dummyradius),0,360); myg.setColor(Color.black); myg.drawLine((int)(dumosc.x),(int)(dumosc.y), (int)(dumnow.x),(int)(dumnow.y)); } } public int typeK(double k[],int i,int max){ double dn1,dn2,dn3; if(i==0){ dn1 =k[max-1]; dn2 =k[i]; dn3 =k[i+1]; }else if(i==-1){ dn1 =k[max-1+i]; dn2 =k[max-1]; dn3 =k[i+1]; }else if(i==-2){ dn1 =k[max-1+i]; dn2 =k[max + i]; dn3 =k[max-1]; }else if(i<-2){ dn1 =k[max-1+i]; dn2 =k[max +i]; dn3 =k[max+1+i]; }else if(i==(max-1)){ dn1 =k[i-1]; dn2 =k[i]; dn3 =k[0]; }else if(i==(max)){ dn1 =k[max-1]; dn2 =k[0]; dn3 =k[1]; }else if(i==(max+1)){ dn1 =k[0]; dn2 =k[1]; dn3 =k[2]; }else if(i>(max+1)){ dn1 =k[i-(max+1)]; dn2 =k[i-(max+1)+1]; dn3 =k[i-(max+1)+2]; }else{ dn1 =k[i-1]; dn2 =k[i]; dn3 =k[i+1]; } if(dn2< 0.0 && dn2< dn3 && dn2< dn1){ return 1;/* minimum */ }else if(dn2<0.0 && dn2> dn3 && dn2> dn1){ return 2;/*n maximum */ }else if(dn2>0.0 && dn2< dn3 && dn2< dn1){ return 3;/*p minimum */ }else if(dn2>0.0 && dn2> dn3 && dn2> dn1){ return 4;/*p maximum */ }else{ return 0; } } public void makeSkeleton1(){ //Cursor nowcursor = this.getCursor(); //this.setCursor(new Cursor(Cursor.WAIT_CURSOR)); //System.out.println("Bi-Tangental Circle"); double t,maxarry; int i,j=0; DoubleVector dumnow,dumn,ddnowummy; dumnow = new DoubleVector(0,0); dumn = new DoubleVector(0,0); medialaxes.listinitialize(); Polygon dummyBound = new Polygon(); double stepsize=1.0; double beforePARAM = mycurve.PARAM; mycurve.changePARAM(((double)(stepsize*mycurve.PARAM))); maxarry = ((double)(mycurve.numberofpoint/(mycurve.PARAM))); double k[] = new double[((int)(maxarry))+2]; int nume=0; int swtypek=0; for(i=0,t = 0;t<=((double)((mycurve).numberofpoint)-mycurve.PARAM);t+=(mycurve.PARAM),i++)k[i] = mycurve.getK(t); double kmin=k[0]; for(i=0,t = 0;t<=((double)((mycurve).numberofpoint)-mycurve.PARAM);t+=(mycurve.PARAM),i++){ if(k[i]=1000){ System.out.println("Over ! iter: May be self-intersection occur !"); break; } } }else{ sw=0; j=0; while(sw==0){ nnn = medialaxes.Head; while(next(nnn)!=medialaxes.Tail){ nnn = next(nnn); if(Incircle(dummy,now,nnn)){ sw=1; break; } } if(sw==1)break; dummy += dummy/100.0; j++; if(j>=1000){ System.out.println("Over ! itre: May be self-intersection occur !"); break; } } } now.speed = dummy; i++; } } // myg.setColor(Color.red); now = medialaxes.Head; while(next(next(now))!=medialaxes.Tail){ now = next(now); if(now.userdef==0&&next(now).userdef==0){ Skeleton_Buffer2[skepointer] = new Vertex(now.x,now.y); Skeleton_Buffer2[skepointer].normal = new DoubleVector(now.normal.x,now.normal.y); Skeleton_Buffer2[skepointer].tangent = new DoubleVector(now.tangent.x,now.tangent.y); Skeleton_Buffer2[skepointer].speed = now.speed; Skeleton_Buffer2[skepointer].next = new Vertex(next(now).x,next(now).y); Skeleton_Buffer2[skepointer].next.normal = new DoubleVector(next(now).normal.x,next(now).normal.y); Skeleton_Buffer2[skepointer].next.speed = next(now).speed; skepointer++; } } now = next(now); if(now.userdef==0&&next(medialaxes.Head).userdef==0){ Skeleton_Buffer2[skepointer] = new Vertex(now.x,now.y); Skeleton_Buffer2[skepointer].normal = new DoubleVector(now.normal.x,now.normal.y); Skeleton_Buffer2[skepointer].tangent = new DoubleVector(now.tangent.x,now.tangent.y); Skeleton_Buffer2[skepointer].speed = now.speed; Skeleton_Buffer2[skepointer].next = new Vertex(next(medialaxes.Head).x,next(medialaxes.Head).y); Skeleton_Buffer2[skepointer].next.normal = new DoubleVector(next(medialaxes.Head).normal.x, next(medialaxes.Head).normal.y); Skeleton_Buffer2[skepointer].next.speed = next(medialaxes.Head).speed; skepointer++; } mycurve.changePARAM(beforePARAM); numberofSkeleton_Buffer2 = skepointer; //this.setCursor(nowcursor); } public void drawSkeleton1R(Graphics myg){ myg.setColor(deeppink); //System.out.println("Bi-Tangental Circle"); double t,maxarry; int i,j=0; DoubleVector dumnow,dumn,ddnowummy; dumnow = new DoubleVector(0,0); dumn = new DoubleVector(0,0); double dummyradius,dx,dy,dummy; medialaxes.listinitialize(); Polygon dummyBound = new Polygon(); double stepsize=1.0; double beforePARAM = mycurve.PARAM; mycurve.changePARAM(((double)(stepsize*mycurve.PARAM))); maxarry = ((double)(mycurve.numberofpoint/(mycurve.PARAM))); double k[] = new double[((int)(maxarry))+2]; int nume=0; int swtypek=0; for(i=0,t = 0;t<=((double)((mycurve).numberofpoint)-mycurve.PARAM);t+=(mycurve.PARAM),i++)k[i] = mycurve.getK(t); double kmin=k[0]; for(i=0,t = 0;t<=((double)((mycurve).numberofpoint)-mycurve.PARAM);t+=(mycurve.PARAM),i++){ if(k[i]=1000){ System.out.println("Over ! iter: May be self-intersection occur !"); break; } } }else{ sw=0; j=0; while(sw==0){ nnn = medialaxes.Head; while(next(nnn)!=medialaxes.Tail){ nnn = next(nnn); if(Incircle(dummy,now,nnn)){ sw=1; break; } } if(sw==1)break; dummy += dummy/100.0; j++; if(j>=1000){ System.out.println("Over ! itre: May be self-intersection occur !"); break; } } } now.speed = dummy; i++; } } // myg.setColor(Color.red); now = medialaxes.Head; while(next(next(now))!=medialaxes.Tail){ now = next(now); if(now.userdef==0&&next(now).userdef==0){ Skeleton_Buffer2[skepointer] = new Vertex(now.x,now.y); Skeleton_Buffer2[skepointer].normal = new DoubleVector(now.normal.x,now.normal.y); Skeleton_Buffer2[skepointer].tangent = new DoubleVector(now.tangent.x,now.tangent.y); Skeleton_Buffer2[skepointer].speed = now.speed; Skeleton_Buffer2[skepointer].next = new Vertex(next(now).x,next(now).y); Skeleton_Buffer2[skepointer].next.normal = new DoubleVector(next(now).normal.x,next(now).normal.y); Skeleton_Buffer2[skepointer].next.speed = next(now).speed; skepointer++; dx = Skeleton_Buffer2[(skepointer-1)].speed *(Skeleton_Buffer2[(skepointer-1)].normal.x) + Skeleton_Buffer2[(skepointer-1)].x; dy = Skeleton_Buffer2[(skepointer-1)].speed *(Skeleton_Buffer2[(skepointer-1)].normal.y) + Skeleton_Buffer2[(skepointer-1)].y; dumnow = Reparametrization(dx,dy); dumn = Reparametrization(Skeleton_Buffer2[(skepointer-1)].x, Skeleton_Buffer2[(skepointer-1)].y); dummyradius = Math.abs((double)(mycurve.scale) *Skeleton_Buffer2[(skepointer-1)].speed); if(skeleton1normal){ myg.setColor(darkorange); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumn.x),(int)(dumn.y)); myg.setColor(deeppink); } if((skepointer-1) % 2 ==0) if(skeleton1circle){ myg.setColor(palevioletred); myg.drawArc((int)(dumnow.x-dummyradius), (int)(dumnow.y-dummyradius), (int)(2.0*dummyradius), (int)(2.0*dummyradius),0,360); myg.setColor(deeppink); } if(skeleton1center){ myg.setColor(teal); myg.fillArc((int)(dumnow.x - 0.05*mycurve.scale), (int)(dumnow.y - 0.05*mycurve.scale), (int)(0.1*mycurve.scale),(int)(0.1*mycurve.scale),0,360); myg.setColor(deeppink); } dx = Skeleton_Buffer2[(skepointer-1)].next.speed *(Skeleton_Buffer2[(skepointer-1)].next.normal.x) + Skeleton_Buffer2[(skepointer-1)].next.x; dy = Skeleton_Buffer2[(skepointer-1)].next.speed *(Skeleton_Buffer2[(skepointer-1)].next.normal.y) + Skeleton_Buffer2[(skepointer-1)].next.y; dumn = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumn.x),(int)(dumn.y)); } } now = next(now); if(now.userdef==0&&next(medialaxes.Head).userdef==0){ Skeleton_Buffer2[skepointer] = new Vertex(now.x,now.y); Skeleton_Buffer2[skepointer].normal = new DoubleVector(now.normal.x,now.normal.y); Skeleton_Buffer2[skepointer].tangent = new DoubleVector(now.tangent.x,now.tangent.y); Skeleton_Buffer2[skepointer].speed = now.speed; Skeleton_Buffer2[skepointer].next = new Vertex(next(medialaxes.Head).x,next(medialaxes.Head).y); Skeleton_Buffer2[skepointer].next.normal = new DoubleVector(next(medialaxes.Head).normal.x, next(medialaxes.Head).normal.y); Skeleton_Buffer2[skepointer].next.speed = next(medialaxes.Head).speed; skepointer++; dx = Skeleton_Buffer2[(skepointer-1)].speed *(Skeleton_Buffer2[(skepointer-1)].normal.x) + Skeleton_Buffer2[(skepointer-1)].x; dy = Skeleton_Buffer2[(skepointer-1)].speed *(Skeleton_Buffer2[(skepointer-1)].normal.y) + Skeleton_Buffer2[(skepointer-1)].y; dumnow = Reparametrization(dx,dy); dumn = Reparametrization(Skeleton_Buffer2[(skepointer-1)].x, Skeleton_Buffer2[(skepointer-1)].y); dummyradius = Math.abs((double)(mycurve.scale) *Skeleton_Buffer2[(skepointer-1)].speed); if(skeleton1normal){ myg.setColor(darkorange); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumn.x),(int)(dumn.y)); myg.setColor(deeppink); } if(i % 2 ==0) if(skeleton1circle){ myg.setColor(palevioletred); myg.drawArc((int)(dumnow.x-dummyradius), (int)(dumnow.y-dummyradius), (int)(2.0*dummyradius), (int)(2.0*dummyradius),0,360); myg.setColor(deeppink); } if(skeleton1center){ myg.setColor(teal); myg.fillArc((int)(dumnow.x - 0.05*mycurve.scale), (int)(dumnow.y - 0.05*mycurve.scale), (int)(0.1*mycurve.scale),(int)(0.1*mycurve.scale),0,360); myg.setColor(deeppink); } dx = Skeleton_Buffer2[(skepointer-1)].next.speed *(Skeleton_Buffer2[(skepointer-1)].next.normal.x) + Skeleton_Buffer2[(skepointer-1)].next.x; dy = Skeleton_Buffer2[(skepointer-1)].next.speed *(Skeleton_Buffer2[(skepointer-1)].next.normal.y) + Skeleton_Buffer2[(skepointer-1)].next.y; dumn = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumn.x),(int)(dumn.y)); } if(skeleton1movin){ myg.setColor(mediumorchid); DoubleVector dske = new DoubleVector(Skeleton_Buffer2[paramske].x, Skeleton_Buffer2[paramske].y); SkePoint.x = dske.x; SkePoint.y = dske.y; DoubleVector dumske = Reparametrization(SkePoint.x,SkePoint.y); myg.fillArc((int)(dumske.x - 0.1*mycurve.scale), (int)(dumske.y - 0.1*mycurve.scale), (int)(0.2*mycurve.scale),(int)(0.2*mycurve.scale),0,360); myg.setColor(forestgreen); SkePoint.normal = new DoubleVector(Skeleton_Buffer2[paramske].normal.x, Skeleton_Buffer2[paramske].normal.y); double dumscale; dummy = (Skeleton_Buffer2[paramske].speed); dx = (SkePoint.x + dummy*(SkePoint.normal).x); dy = (SkePoint.y + dummy*(SkePoint.normal).y); dumnow = Reparametrization(dx,dy); dummyradius = mycurve.scale*Math.abs(dummy); myg.drawArc((int)(dumnow.x -dummyradius), (int)(dumnow.y -dummyradius), (int)(2.0*dummyradius), (int)(2.0*dummyradius),0,360); myg.setColor(Color.black); myg.drawLine((int)(dumske.x),(int)(dumske.y), (int)(dumnow.x),(int)(dumnow.y)); } mycurve.changePARAM(beforePARAM); numberofSkeleton_Buffer2 = skepointer; myg.setColor(Color.black); } public void drawSkeleton1(Graphics myg){ myg.setColor(deeppink); //Cursor nowcursor = this.getCursor(); //this.setCursor(new Cursor(Cursor.WAIT_CURSOR)); //System.out.println("Bi-Tangental Circle"); double t,maxarry; int i,j=0; double dummyradius,dx,dy; DoubleVector dumnow,dumn; dumnow = new DoubleVector(0,0); dumn = new DoubleVector(0,0); for(i=0;i=1000){ System.out.println("Over ! itre: May be self-intersection occur !"); break; } } } now.speed = dummy; i++; } } now = medialaxes.Head; while(next(next(now))!=medialaxes.Tail){ now = next(now); if(now.userdef==0&&next(now).userdef==0){ fcurve.Skeleton_Buffer2[skepointer] = new Vertex(now.x,now.y); fcurve.Skeleton_Buffer2[skepointer].normal = new DoubleVector(now.normal.x,now.normal.y); fcurve.Skeleton_Buffer2[skepointer].tangent = new DoubleVector(now.tangent.x,now.tangent.y); fcurve.Skeleton_Buffer2[skepointer].speed = now.speed; fcurve.Skeleton_Buffer2[skepointer].next = new Vertex(next(now).x,next(now).y); fcurve.Skeleton_Buffer2[skepointer].next.normal = new DoubleVector(next(now).normal.x,next(now).normal.y); fcurve.Skeleton_Buffer2[skepointer].next.speed = next(now).speed; skepointer++; } } now = next(now); if(now.userdef==0&&next(medialaxes.Head).userdef==0){ fcurve.Skeleton_Buffer2[skepointer] = new Vertex(now.x,now.y); fcurve.Skeleton_Buffer2[skepointer].normal = new DoubleVector(now.normal.x,now.normal.y); fcurve.Skeleton_Buffer2[skepointer].tangent = new DoubleVector(now.tangent.x,now.tangent.y); fcurve.Skeleton_Buffer2[skepointer].speed = now.speed; fcurve.Skeleton_Buffer2[skepointer].next = new Vertex(next(medialaxes.Head).x,next(medialaxes.Head).y); fcurve.Skeleton_Buffer2[skepointer].next.normal = new DoubleVector(next(medialaxes.Head).normal.x, next(medialaxes.Head).normal.y); fcurve.Skeleton_Buffer2[skepointer].next.speed = next(medialaxes.Head).speed; skepointer++; } mycurve.changePARAM(beforePARAM); fcurve.numberofSkeleton_Buffer2 = skepointer; double dj; DoubleVector dumnow1,dumnow2; myg.setColor(Color.blue); for(i=0;i Math.abs(fcurve.Skeleton_Buffer2[i].speed)){ contcheck++; }else{ dx = fcurve.Skeleton_Buffer2[i].x - dj*((fcurve.Skeleton_Buffer2[i]).normal).x; dy = fcurve.Skeleton_Buffer2[i].y - dj*((fcurve.Skeleton_Buffer2[i]).normal).y; dummylevel.Append(new DoubleVector(dx,dy),0); } } now = dummylevel.Head; if(next(now)==dummylevel.Tail){ contcheck = fcurve.numberofSkeleton_Buffer2;break; } while(next(next(now))!=dummylevel.Tail){ now = next(now); dumnow1 = Reparametrization(now.x,now.y); dumnow2 = Reparametrization(next(now).x,next(now).y); myg.drawLine((int)(dumnow1.x),(int)(dumnow1.y), (int)(dumnow2.x),(int)(dumnow2.y)); } now = next(now); dumnow1 = Reparametrization(now.x,now.y); dumnow2 = Reparametrization(next(dummylevel.Head).x, next(dummylevel.Head).y); myg.drawLine((int)(dumnow1.x),(int)(dumnow1.y), (int)(dumnow2.x),(int)(dumnow2.y)); } if(contcheck >= fcurve.numberofSkeleton_Buffer2-1)break; } myg.setColor(Color.black); } public void drawContourR(Graphics myg){ int i,j,m; myg.setColor(Color.blue); double t,maxarry; DoubleVector dumnow,dumn,ddnowummy; dumnow = new DoubleVector(0,0); dumn = new DoubleVector(0,0); medialaxes.listinitialize(); medialaxes.height = ((double)(aread.height)); double stepsize=1.0; double beforePARAM = mycurve.PARAM; mycurve.changePARAM(((double)(stepsize*mycurve.PARAM))); maxarry = ((double)(mycurve.numberofpoint/(mycurve.PARAM))); double k[] = new double[((int)(maxarry))+2]; int nume=0; int swtypek=0; for(i=0,t = 0;t<=((double)((mycurve).numberofpoint)-mycurve.PARAM);t+=(mycurve.PARAM),i++)k[i] = mycurve.getK(t); double kmin=k[0]; for(i=0,t = 0;t<=((double)((mycurve).numberofpoint)-mycurve.PARAM);t+=(mycurve.PARAM),i++){ swtypek = typeK(k,i,((int)(maxarry))); if(swtypek ==1){ nume++; if(k[i]=1000){ System.out.println("Over ! iter: May be self-intersection occur !"); break; } } }else{ sw=0; j=0; while(sw==0){ nnn = medialaxes.Head; while(next(nnn)!=medialaxes.Tail){ nnn = next(nnn); if(Incircle(dummy,now,nnn)){ sw=1; break; } } if(sw==1)break; dummy += dummy/100.0; j++; if(j>=1000){ System.out.println("Over ! itre: May be self-intersection occur !"); break; } } } now.speed = dummy; i++; } } now = medialaxes.Head; while(next(next(now))!=medialaxes.Tail){ now = next(now); if(now.userdef==0&&next(now).userdef==0){ fcurve.Skeleton_Buffer2[skepointer] = new Vertex(now.x,now.y); fcurve.Skeleton_Buffer2[skepointer].normal = new DoubleVector(now.normal.x,now.normal.y); fcurve.Skeleton_Buffer2[skepointer].tangent = new DoubleVector(now.tangent.x,now.tangent.y); fcurve.Skeleton_Buffer2[skepointer].speed = now.speed; fcurve.Skeleton_Buffer2[skepointer].next = new Vertex(next(now).x,next(now).y); fcurve.Skeleton_Buffer2[skepointer].next.normal = new DoubleVector(next(now).normal.x,next(now).normal.y); fcurve.Skeleton_Buffer2[skepointer].next.speed = next(now).speed; skepointer++; } } now = next(now); if(now.userdef==0&&next(medialaxes.Head).userdef==0){ fcurve.Skeleton_Buffer2[skepointer] = new Vertex(now.x,now.y); fcurve.Skeleton_Buffer2[skepointer].normal = new DoubleVector(now.normal.x,now.normal.y); fcurve.Skeleton_Buffer2[skepointer].tangent = new DoubleVector(now.tangent.x,now.tangent.y); fcurve.Skeleton_Buffer2[skepointer].speed = now.speed; fcurve.Skeleton_Buffer2[skepointer].next = new Vertex(next(medialaxes.Head).x,next(medialaxes.Head).y); fcurve.Skeleton_Buffer2[skepointer].next.normal = new DoubleVector(next(medialaxes.Head).normal.x, next(medialaxes.Head).normal.y); fcurve.Skeleton_Buffer2[skepointer].next.speed = next(medialaxes.Head).speed; skepointer++; } mycurve.changePARAM(beforePARAM); fcurve.numberofSkeleton_Buffer2 = skepointer; } public void makeContour(){ Cursor nowcursor = this.getCursor(); this.setCursor(new Cursor(Cursor.WAIT_CURSOR)); double t,maxarry; int i; DoubleVector dumnow,dumn,ddnowummy; dumnow = new DoubleVector(0,0); dumn = new DoubleVector(0,0); medialaxes.listinitialize(); medialaxes.height = ((double)(aread.height)); double stepsize=1.0; double beforePARAM = mycurve.PARAM; mycurve.changePARAM(((double)(stepsize*mycurve.PARAM))); maxarry = ((double)(mycurve.numberofpoint/(mycurve.PARAM))); double k[] = new double[((int)(maxarry))+2]; int nume=0; int swtypek=0; for(i=0,t = 0;t<((double)((mycurve).numberofpoint));t+=(mycurve.PARAM),i++)k[i] = mycurve.getK(t); double kmin=k[0]; for(i=0,t = 0;t<((double)((mycurve).numberofpoint));t+=(mycurve.PARAM),i++){ swtypek = typeK(k,i,((int)(maxarry))); if(swtypek ==1){ nume++; if(k[i]((double)(mycurve.numberofpoint))) t = ((double)(mycurve.numberofpoint)); dum1 = mycurve.getPoint(t); inp.addElement(dum1); dum2 = Reparametrization(dum1.x,dum1.y); dummy.addPoint((int)(dum2.x),(int)(dum2.y)); if(checkfirst){ checkfirst = false; t+=0.0000001; } } vgraph.setP(inp); inp.removeAllElements(); Skeleton_Buffer_E = new DoubleVector[(vgraph.getNumberofEdge())]; Skeleton_Buffer_S = new DoubleVector[(vgraph.getNumberofEdge())]; numberofSkeleton_Buffer=0; for(int i=0;i((double)(mycurve.numberofpoint))) t = ((double)(mycurve.numberofpoint)); dum1 = mycurve.getPoint(t); inp.addElement(dum1); dum2 = Reparametrization(dum1.x,dum1.y); dummy.addPoint((int)(dum2.x),(int)(dum2.y)); if(checkfirst){ checkfirst = false; t+=0.0000001; } } vgraph.setP(inp); inp.removeAllElements(); Skeleton_Buffer_E = new DoubleVector[(vgraph.getNumberofEdge())]; Skeleton_Buffer_S = new DoubleVector[(vgraph.getNumberofEdge())]; numberofSkeleton_Buffer=0; for(int i=0;i((double)(mycurve.numberofpoint))) t = ((double)(mycurve.numberofpoint)); dum1 = mycurve.getPoint(t); inp.addElement(dum1); if(checkfirst){ checkfirst = false; t+=0.0000001; } } vgraph.setP(inp); inp.removeAllElements(); numberofVoronoi_Buffer=0; Voronoi_Buffer_S = new DoubleVector[vgraph.getNumberofEdge()]; Voronoi_Buffer_E = new DoubleVector[vgraph.getNumberofEdge()]; double dx,dy; for(int i=0;i((double)(mycurve.numberofpoint))) t = ((double)(mycurve.numberofpoint)); dum1 = mycurve.getPoint(t); inp.addElement(dum1); if(checkfirst){ checkfirst = false; t+=0.0000001; } } vgraph.setP(inp); inp.removeAllElements(); numberofVoronoi_Buffer=0; Voronoi_Buffer_S = new DoubleVector[vgraph.getNumberofEdge()]; Voronoi_Buffer_E = new DoubleVector[vgraph.getNumberofEdge()]; double dx,dy; for(int i=0;i= 0.0 || now.k >= 0.0 && next.k <= 0.0){ myg.setColor(mediumorchid); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (back.x + (1.0/back.k)*((back.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (back.y + (1.0/back.k)*((back.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); myg.setColor(forestgreen); }else if(now.k <= 0.0 && back.k >= 0.0 || now.k >= 0.0 && back.k <= 0.0){ myg.setColor(mediumorchid); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (next.x + (1.0/next.k)*((next.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (next.y + (1.0/next.k)*((next.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); myg.setColor(forestgreen); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); }else{ dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } back = now; now = next; } dnext = mycurve.getOrthotomic(0.0,LightSource); next = new Knot(dnext.x,dnext.y); next.normal = mycurve.getOrthotomicNormal(0.0,LightSource); next.k = mycurve.getOrthotomicK(0.0,LightSource); if(now.k <= 0.0 && next.k >= 0.0 || now.k >= 0.0 && next.k <= 0.0){ myg.setColor(mediumorchid); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (back.x + (1.0/back.k)*((back.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (back.y + (1.0/back.k)*((back.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); myg.setColor(forestgreen); }else if(now.k <= 0.0 && back.k >= 0.0 || now.k >= 0.0 && back.k <= 0.0){ myg.setColor(mediumorchid); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (next.x + (1.0/next.k)*((next.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (next.y + (1.0/next.k)*((next.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); myg.setColor(forestgreen); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); }else{ dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } mycurve.changePARAM(beforePARAM); myg.setColor(Color.black); } public void drawColorCaustic(Graphics myg){ float h = ((float)(0.0)); double stepsize=0.25; double beforePARAM = mycurve.PARAM; mycurve.changePARAM(((double)(stepsize*mycurve.PARAM))); double step = (double)(mycurve.PARAM); DoubleVector direction,dumnow,dumdum,direction2; DoubleVector dback,dnow,dnext; double dx,dy,size; dumnow = new DoubleVector(0.0,0.0); dumdum = new DoubleVector(0.0,0.0); direction = new DoubleVector(0.0,0.0); direction2 = new DoubleVector(0.0,0.0); Knot back,now,next; double length = (10.0 + 1000.0/mycurve.scale); dback = mycurve.getOrthotomic((((double)((mycurve).numberofpoint))),LightSource); back = new Knot(dback.x,dback.y); back.normal = mycurve.getOrthotomicNormal((((double)((mycurve).numberofpoint))),LightSource); back.k = mycurve.getOrthotomicK((((double)((mycurve).numberofpoint))),LightSource); double t = 0.0; dnow = mycurve.getOrthotomic(t,LightSource); now = new Knot(dnow.x,dnow.y); now.normal = mycurve.getOrthotomicNormal(t,LightSource); now.k = mycurve.getOrthotomicK(t,LightSource); for(t = 0.0; t<=((double)((mycurve).numberofpoint) - step); t+=step){ h = (float)(t/((float)(mycurve.numberofpoint))); myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); dnext = mycurve.getOrthotomic((t+step),LightSource); next = new Knot(dnext.x,dnext.y); next.normal = mycurve.getOrthotomicNormal((t+step),LightSource); next.k = mycurve.getOrthotomicK((t+step),LightSource); if(now.k <= 0.0 && next.k >= 0.0 || now.k >= 0.0 && next.k <= 0.0){ myg.setColor(mediumorchid); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (back.x + (1.0/back.k)*((back.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (back.y + (1.0/back.k)*((back.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); myg.setColor(forestgreen); }else if(now.k <= 0.0 && back.k >= 0.0 || now.k >= 0.0 && back.k <= 0.0){ myg.setColor(mediumorchid); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (next.x + (1.0/next.k)*((next.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (next.y + (1.0/next.k)*((next.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); myg.setColor(forestgreen); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); }else{ dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } back = now; now = next; } dnext = mycurve.getOrthotomic(0.0,LightSource); next = new Knot(dnext.x,dnext.y); next.normal = mycurve.getOrthotomicNormal(0.0,LightSource); next.k = mycurve.getOrthotomicK(0.0,LightSource); if(now.k <= 0.0 && next.k >= 0.0 || now.k >= 0.0 && next.k <= 0.0){ myg.setColor(mediumorchid); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (back.x + (1.0/back.k)*((back.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (back.y + (1.0/back.k)*((back.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); myg.setColor(forestgreen); }else if(now.k <= 0.0 && back.k >= 0.0 || now.k >= 0.0 && back.k <= 0.0){ myg.setColor(mediumorchid); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (next.x + (1.0/next.k)*((next.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (next.y + (1.0/next.k)*((next.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); myg.setColor(forestgreen); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); }else{ dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } mycurve.changePARAM(beforePARAM); myg.setColor(Color.black); } public void drawosculating(Graphics myg) { myg.setColor(tomato); double length = (10.0 + 1000.0/mycurve.scale); DoubleVector dnow,dumnow,dumosc; Knot now; double dx,dy; for(double t = 0.0; t<=((double)((mycurve).numberofpoint-(2.0*mycurve.PARAM))); t+=(2.0*mycurve.PARAM)){ dnow = mycurve.getPoint(t); now = new Knot(dnow.x,dnow.y); now.normal = mycurve.getNormal(t); now.k = mycurve.getK(t); if(Math.abs(now.k)<=0.00000000001){ now.tangent = mycurve.getTangent(t); dx = (now.x + length*(now.tangent).x); dy = (now.y + length*(now.tangent).y); dumnow = Reparametrization(dx,dy); dx = (now.x - length*(now.tangent).x); dy = (now.y - length*(now.tangent).y); dumosc = Reparametrization(dx,dy); myg.drawLine((int)(dumosc.x),(int)(dumosc.y), (int)(dumnow.x),(int)(dumnow.y)); }else{ double dummy = (1.0/now.k); dx = (now.x + dummy*(now.normal).x); dy = (now.y + dummy*(now.normal).y); dumnow = Reparametrization(dx,dy); double dummyradius = (mycurve.scale)*Math.abs(dummy); myg.drawArc((int)(dumnow.x-dummyradius), (int)(dumnow.y-dummyradius), (int)(2.0*dummyradius), (int)(2.0*dummyradius),0,360); } } myg.setColor(Color.black); } public void drawColorosculating(Graphics myg) { float h = ((float)(0.0)); double length = (10.0 + 1000.0/mycurve.scale); DoubleVector dnow,dumnow,dumosc; Knot now; double dx,dy; for(double t = 0.0; t<=((double)((mycurve).numberofpoint-(2.0*mycurve.PARAM))); t+=(2.0*mycurve.PARAM)){ h = (float)(t/((float)(mycurve.numberofpoint))); myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); dnow = mycurve.getPoint(t); now = new Knot(dnow.x,dnow.y); now.normal = mycurve.getNormal(t); now.k = mycurve.getK(t); if(Math.abs(now.k)<=0.00000000001){ now.tangent = mycurve.getTangent(t); dx = (now.x + length*(now.tangent).x); dy = (now.y + length*(now.tangent).y); dumnow = Reparametrization(dx,dy); dx = (now.x - length*(now.tangent).x); dy = (now.y - length*(now.tangent).y); dumosc = Reparametrization(dx,dy); myg.drawLine((int)(dumosc.x),(int)(dumosc.y), (int)(dumnow.x),(int)(dumnow.y)); }else{ double dummy = (1.0/now.k); dx = (now.x + dummy*(now.normal).x); dy = (now.y + dummy*(now.normal).y); dumnow = Reparametrization(dx,dy); double dummyradius = (mycurve.scale)*Math.abs(dummy); myg.drawArc((int)(dumnow.x-dummyradius), (int)(dumnow.y-dummyradius), (int)(2.0*dummyradius), (int)(2.0*dummyradius),0,360); } } myg.setColor(Color.black); } public void drawtangent(Graphics myg) { myg.setColor(cornflowerblue); DoubleVector dnow,dumdum,dumnow,da1,da2; Knot now; double dx,dy; Arrow mya; for(double t = 0.0; t<=((double)((mycurve).numberofpoint)); t+=mycurve.PARAM){ dnow = mycurve.getPoint(t); now = new Knot(dnow.x,dnow.y); now.tangent = mycurve.getTangent(t); dumnow = Reparametrization(now.x,now.y); dx = (now.x + 0.7*(now.tangent).x); dy = (now.y + 0.7*(now.tangent).y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); da1 = new DoubleVector(dumnow.x,dumnow.y); da2 = new DoubleVector(dumdum.x,dumdum.y); mya = new Arrow(da1,da2); myg.fillPolygon(mya); } myg.setColor(Color.black); } public void drawCurvature(Graphics myg) { myg.setColor(Color.magenta); DoubleVector dnow,dumnow,dumdum; Knot now; double dx,dy; for(double t = 0.0; t<=((double)((mycurve).numberofpoint)); t+=mycurve.PARAM){ dnow = mycurve.getPoint(t); now = new Knot(dnow.x,dnow.y); now.normal = mycurve.getNormal(t); now.k = mycurve.getK(t); dumnow = Reparametrization(now.x,now.y); dx = (now.x + 0.5*(now.k)*(now.normal).x); dy = (now.y + 0.5*(now.k)*(now.normal).y); dumdum = Reparametrization(dx,dy); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } myg.setColor(Color.black); } public void drawColorEvolute(Graphics myg) { float h = ((float)(0.0)); myg.setColor(Color.blue); double step = (double)(mycurve.PARAM); double length = (10.0 + 1000.0/mycurve.scale); DoubleVector direction,dumnow,dumdum,direction2; DoubleVector dback,dnow,dnext; Polygon BoundingBox = new Polygon(); BoundingBox.addPoint(-1005,-1005); BoundingBox.addPoint(-1005,1405); BoundingBox.addPoint(1805,1405); BoundingBox.addPoint(1805,-1005); double dx,dy,size; dumnow = new DoubleVector(0.0,0.0); dumdum = new DoubleVector(0.0,0.0); direction = new DoubleVector(0.0,0.0); direction2 = new DoubleVector(0.0,0.0); Knot back,now,next; dback = mycurve.getPoint((((double)((mycurve).numberofpoint)))); back = new Knot(dback.x,dback.y); back.normal = mycurve.getNormal((((double)((mycurve).numberofpoint)))); back.k = mycurve.getK((((double)((mycurve).numberofpoint)))); double t = 0.0; dnow = mycurve.getPoint(t); now = new Knot(dnow.x,dnow.y); now.normal = mycurve.getNormal(t); now.k = mycurve.getK(t); for(t = 0.0; t<=((double)((mycurve).numberofpoint) - step); t+=step){ h = (float)(t/((float)(mycurve.numberofpoint))); myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); dnext = mycurve.getPoint((t+step)); next = new Knot(dnext.x,dnext.y); next.normal = mycurve.getNormal((t+step)); next.k = mycurve.getK((t+step)); if(now.k <= 0.0 && next.k >= 0.0 || now.k >= 0.0 && next.k <= 0.0){ myg.setColor(teal); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (back.x + (1.0/back.k)*((back.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (back.y + (1.0/back.k)*((back.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); }else if(now.k <= 0.0 && back.k >= 0.0 || now.k >= 0.0 && back.k <= 0.0){ myg.setColor(teal); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (next.x + (1.0/next.k)*((next.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (next.y + (1.0/next.k)*((next.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } }else{ dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } } back = now; now = next; } h = (float)((t+step)/((float)(mycurve.numberofpoint))); dnext = mycurve.getPoint(0.0); next = new Knot(dnext.x,dnext.y); next.normal = mycurve.getNormal(0.0); next.k = mycurve.getK(0.0); if(now.k <= 0.0 && next.k >= 0.0 || now.k >= 0.0 && next.k <= 0.0){ myg.setColor(teal); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (back.x + (1.0/back.k)*((back.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (back.y + (1.0/back.k)*((back.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); }else if(now.k <= 0.0 && back.k >= 0.0 || now.k >= 0.0 && back.k <= 0.0){ myg.setColor(teal); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (next.x + (1.0/next.k)*((next.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (next.y + (1.0/next.k)*((next.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } }else{ dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } } myg.setColor(Color.black); } /* CopyRight Shin Yoshizawa 2000, 2, 13 Univ Aizu */ public void drawEvolute(Graphics myg) { myg.setColor(Color.blue); Polygon BoundingBox = new Polygon(); BoundingBox.addPoint(-1005,-1005); BoundingBox.addPoint(-1005,1405); BoundingBox.addPoint(1805,1405); BoundingBox.addPoint(1805,-1005); double step = (double)(mycurve.PARAM); double length = (10.0 + 1000.0/mycurve.scale); DoubleVector direction,dumnow,dumdum,direction2; DoubleVector dback,dnow,dnext; double dx,dy,size; dumnow = new DoubleVector(0.0,0.0); dumdum = new DoubleVector(0.0,0.0); direction = new DoubleVector(0.0,0.0); direction2 = new DoubleVector(0.0,0.0); Knot back,now,next; dback = mycurve.getPoint((((double)((mycurve).numberofpoint)))); back = new Knot(dback.x,dback.y); back.normal = mycurve.getNormal((((double)((mycurve).numberofpoint)))); back.k = mycurve.getK((((double)((mycurve).numberofpoint)))); double t = 0.0; dnow = mycurve.getPoint(t); now = new Knot(dnow.x,dnow.y); now.normal = mycurve.getNormal(t); now.k = mycurve.getK(t); //System.out.println(" "); for(t = 0.0; t<=((double)((mycurve).numberofpoint) - step); t+=step){ dnext = mycurve.getPoint((t+step)); next = new Knot(dnext.x,dnext.y); next.normal = mycurve.getNormal((t+step)); next.k = mycurve.getK((t+step)); //System.out.println("k = "+now.k); if(now.k <= 0.0 && next.k >= 0.0 || now.k >= 0.0 && next.k <= 0.0){ myg.setColor(teal); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (back.x + (1.0/back.k)*((back.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (back.y + (1.0/back.k)*((back.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } myg.setColor(Color.blue); }else if(now.k <= 0.0 && back.k >= 0.0 || now.k >= 0.0 && back.k <= 0.0){ myg.setColor(teal); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (next.x + (1.0/next.k)*((next.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (next.y + (1.0/next.k)*((next.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } myg.setColor(Color.blue); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } }else{ dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } } back = now; now = next; } dnext = mycurve.getPoint(0.0); next = new Knot(dnext.x,dnext.y); next.normal = mycurve.getNormal(0.0); next.k = mycurve.getK(0.0); if(now.k <= 0.0 && next.k >= 0.0 || now.k >= 0.0 && next.k <= 0.0){ myg.setColor(teal); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (back.x + (1.0/back.k)*((back.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (back.y + (1.0/back.k)*((back.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } myg.setColor(Color.blue); }else if(now.k <= 0.0 && back.k >= 0.0 || now.k >= 0.0 && back.k <= 0.0){ myg.setColor(teal); dx = ((now.x + (1.0/now.k)*((now.normal).x)) - (next.x + (1.0/next.k)*((next.normal).x))); dy = ((now.y + (1.0/now.k)*((now.normal).y)) - (next.y + (1.0/next.k)*((next.normal).y))); size = Math.sqrt((dx*dx + dy*dy)); if(size == 0.0) size = 1.0; direction.x = (dx/size); direction.y = (dy/size); dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/now.k)*(now.normal).x + now.x + length*direction.x); dy = ((1.0/now.k)*(now.normal).y + now.y + length*direction.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } myg.setColor(Color.blue); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } }else{ dx = ((1.0/now.k)*(now.normal).x + now.x); dy = ((1.0/now.k)*(now.normal).y + now.y); dumnow = Reparametrization(dx,dy); dx = ((1.0/next.k)*(next.normal).x + next.x); dy = ((1.0/next.k)*(next.normal).y + next.y); dumdum = Reparametrization(dx,dy); if((!BoundingBox.contains((int)(dumnow.x),(int)(dumnow.y)))&& (!BoundingBox.contains((int)(dumdum.x),(int)(dumdum.y)))){}else{ myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumdum.x),(int)(dumdum.y)); } } myg.setColor(Color.black); } public void draw(Graphics g ){ Dimension d = new Dimension(); d.width = dd.width -10; d.height = dd.height - 90; double nx; double ny; dg.setColor(Color.white); dg.fillRect(0,0,dd.width,dd.height); dg.setColor(Color.black); double deforePARAM = mycurve.PARAM; if(mycurve.numberofpoint>=5){ mycurve.changePARAM(0.05); if(orsw==1){ if(!Rating[10]){ if(orcolorsw==1){ this.drawColorOrthotomic(dg); }else{ this.drawOrthotomic(dg); } }else{ mycurve.changePARAM(deforePARAM); if(orcolorsw==1){ this.drawColorOrthotomic(dg); }else{ this.drawOrthotomic(dg); } mycurve.changePARAM(0.05); } } if(norsw==1){ if(!Rating[11]){ if(norcolorsw==1){ this.drawColorFNOrthotomic(dg); }else{ this.drawFNOrthotomic(dg); } }else{ mycurve.changePARAM(deforePARAM); if(norcolorsw==1){ this.drawColorFNOrthotomic(dg); }else{ this.drawFNOrthotomic(dg); } mycurve.changePARAM(0.05); } } if(casw==1){ if(!Rating[12]){ if(cacolorsw==1){ this.drawColorCaustic(dg); }else{ this.drawCaustic(dg); } }else{ mycurve.changePARAM(deforePARAM); if(cacolorsw==1){ this.drawColorCaustic(dg); }else{ this.drawCaustic(dg); } mycurve.changePARAM(0.05); } } if((casw==1)||(norsw==1)||(orsw==1)){ dg.setColor(Color.red); DoubleVector dumlight = Reparametrization(LightSource.x,LightSource.y); dg.fillArc((int)(dumlight.x - 0.1*mycurve.scale), (int)(dumlight.y - 0.1*mycurve.scale), (int)(0.2*mycurve.scale),(int)(0.2*mycurve.scale),0,360); dg.setColor(Color.black); } if(contourmap) this.drawContour(dg); if(laplace) this.drawLaplace(dg); if(cdriven1) this.drawCDriven(dg); if(cdriven2) this.drawCDriven2(dg); if(skeleton1){ if(!Rating[13]){ this.drawSkeleton1(dg); }else{ mycurve.changePARAM(deforePARAM); this.drawSkeleton1(dg); mycurve.changePARAM(0.05); } } if(voronoid){ if(!Rating[15]){ this.drawVoronoi(dg); }else{ mycurve.changePARAM(deforePARAM); this.drawVoronoi(dg); mycurve.changePARAM(0.05); } } if(skeleton2){ if(!Rating[14]){ this.drawSkeleton2(dg); }else{ mycurve.changePARAM(deforePARAM); this.drawSkeleton2(dg); mycurve.changePARAM(0.05); } } if(fnsw==1){ if(!Rating[7]){ if(fncolorsw==1){ this.drawColorenvelop(dg); }else{ this.drawenvelop(dg); } }else{ mycurve.changePARAM(deforePARAM); if(fncolorsw==1){ this.drawColorenvelop(dg); }else{ this.drawenvelop(dg); } mycurve.changePARAM(0.05); } } if(esw==1){ if(!Rating[9]){ if(evcolorsw==1){ this.drawColorEvolute(dg); }else{ this.drawEvolute(dg); } }else{ mycurve.changePARAM(deforePARAM); if(evcolorsw==1){ this.drawColorEvolute(dg); }else{ this.drawEvolute(dg); } mycurve.changePARAM(0.05); } } if(ofsw==1){ if(!Rating[5]){ if(ofcolorsw==1){ this.drawColoroffset(dg); }else{ this.drawoffset(dg); } }else{ mycurve.changePARAM(deforePARAM); if(ofcolorsw==1){ this.drawColoroffset(dg); }else{ this.drawoffset(dg); } mycurve.changePARAM(0.05); } } if(osw==1){ if(!Rating[3]){ if(oscolorsw==1){ drawColorosculating(dg); }else{ drawosculating(dg); } }else{ mycurve.changePARAM(deforePARAM); if(oscolorsw==1){ drawColorosculating(dg); }else{ drawosculating(dg); } mycurve.changePARAM(0.05); } } if(oneosw==1) if(oneoscolorsw==1){ drawColoroneosculating(dg); }else{ drawoneosculating(dg); } if(oneoffsw){ if(!Rating[6]){ if(oneoffcolorsw==1){ drawColoroneoffset(dg); }else{ drawoneoffset(dg); } }else{ mycurve.changePARAM(deforePARAM); if(oneoffcolorsw==1){ drawColoroneoffset(dg); }else{ drawoneoffset(dg); } mycurve.changePARAM(0.05); } } if(onensw) if(onencolorsw==1){ drawColoronenormal(dg); }else{ drawonenormal(dg); } if(nsw==1){ if(!Rating[0]){ drawnormal(dg); }else{ mycurve.changePARAM(deforePARAM); drawnormal(dg); mycurve.changePARAM(0.05); } } if(tsw==1){ if(!Rating[2]){ drawtangent(dg); }else{ mycurve.changePARAM(deforePARAM); drawtangent(dg); mycurve.changePARAM(0.05); } } if(csw==1){ if(!Rating[1]){ drawCurvature(dg); }else{ mycurve.changePARAM(deforePARAM); drawCurvature(dg); mycurve.changePARAM(0.05); } } if(curvev==1) if(cvcolorsw==1){ this.drawColorbspline(dg); }else{ this.drawbspline(dg); } mycurve.changePARAM(deforePARAM); if(samplingvis==1){ mycurve.changePARAM(deforePARAM); if(virtualN != 160){ dg.setColor(teal); }else{ dg.setColor(Color.black); } this.drawbspline(dg); dg.setColor(Color.black); } } if(drawcontrolp==1&&mycurve.numberofpoint>=1){ Knot now = mycurve.Head; DoubleVector dumnow; Color dummyC; while(Next(now)!=mycurve.Tail){ now = Next(now); dumnow = Reparametrization(now.x,now.y); dummyC = dg.getColor(); dg.setColor(now.mycolor); dg.fillArc((int)(dumnow.x - 0.05*mycurve.scale), (int)(dumnow.y - 0.05*mycurve.scale), (int)(0.1*mycurve.scale),(int)(0.1*mycurve.scale),0,360); dg.setColor(dummyC); } } } public void drawR(Graphics g ){ Dimension d = new Dimension(); d.width = dd.width -10; d.height = dd.height - 90; double nx; double ny; dg.setColor(Color.white); dg.fillRect(0,0,dd.width,dd.height); dg.setColor(Color.black); double deforePARAM = mycurve.PARAM; if(mycurve.numberofpoint>=5){ mycurve.changePARAM(0.05); if(orsw==1){ if(!Rating[10]){ if(orcolorsw==1){ this.drawColorOrthotomic(dg); }else{ this.drawOrthotomic(dg); } }else{ mycurve.changePARAM(deforePARAM); if(orcolorsw==1){ this.drawColorOrthotomic(dg); }else{ this.drawOrthotomic(dg); } mycurve.changePARAM(0.05); } } if(norsw==1){ if(!Rating[11]){ if(norcolorsw==1){ this.drawColorFNOrthotomic(dg); }else{ this.drawFNOrthotomic(dg); } }else{ mycurve.changePARAM(deforePARAM); if(norcolorsw==1){ this.drawColorFNOrthotomic(dg); }else{ this.drawFNOrthotomic(dg); } mycurve.changePARAM(0.05); } } if(casw==1){ if(!Rating[12]){ if(cacolorsw==1){ this.drawColorCaustic(dg); }else{ this.drawCaustic(dg); } }else{ mycurve.changePARAM(deforePARAM); if(cacolorsw==1){ this.drawColorCaustic(dg); }else{ this.drawCaustic(dg); } mycurve.changePARAM(0.05); } } if((casw==1)||(norsw==1)||(orsw==1)){ dg.setColor(Color.red); DoubleVector dumlight = Reparametrization(LightSource.x,LightSource.y); dg.fillArc((int)(dumlight.x - 0.1*mycurve.scale), (int)(dumlight.y - 0.1*mycurve.scale), (int)(0.2*mycurve.scale),(int)(0.2*mycurve.scale),0,360); dg.setColor(Color.black); } if(contourmap) this.drawContourR(dg); if(laplace) this.drawLaplaceR(dg); if(cdriven1) this.drawCDrivenR(dg); if(cdriven2) this.drawCDriven2R(dg); if(skeleton1){ if(!Rating[13]){ this.drawSkeleton1R(dg); }else{ mycurve.changePARAM(deforePARAM); this.drawSkeleton1R(dg); mycurve.changePARAM(0.05); } } if(voronoid){ if(!Rating[15]){ this.drawVoronoiR(dg); }else{ mycurve.changePARAM(deforePARAM); this.drawVoronoiR(dg); mycurve.changePARAM(0.05); } } if(skeleton2){ if(!Rating[14]){ this.drawSkeleton2R(dg); }else{ mycurve.changePARAM(deforePARAM); this.drawSkeleton2R(dg); mycurve.changePARAM(0.05); } } if(fnsw==1){ if(!Rating[7]){ if(fncolorsw==1){ this.drawColorenvelop(dg); }else{ this.drawenvelop(dg); } }else{ mycurve.changePARAM(deforePARAM); if(fncolorsw==1){ this.drawColorenvelop(dg); }else{ this.drawenvelop(dg); } mycurve.changePARAM(0.05); } } if(esw==1){ if(!Rating[9]){ if(evcolorsw==1){ this.drawColorEvolute(dg); }else{ this.drawEvolute(dg); } }else{ mycurve.changePARAM(deforePARAM); if(evcolorsw==1){ this.drawColorEvolute(dg); }else{ this.drawEvolute(dg); } mycurve.changePARAM(0.05); } } if(ofsw==1){ if(!Rating[5]){ if(ofcolorsw==1){ this.drawColoroffset(dg); }else{ this.drawoffset(dg); } }else{ mycurve.changePARAM(deforePARAM); if(ofcolorsw==1){ this.drawColoroffset(dg); }else{ this.drawoffset(dg); } mycurve.changePARAM(0.05); } } if(osw==1){ if(!Rating[3]){ if(oscolorsw==1){ drawColorosculating(dg); }else{ drawosculating(dg); } }else{ mycurve.changePARAM(deforePARAM); if(oscolorsw==1){ drawColorosculating(dg); }else{ drawosculating(dg); } mycurve.changePARAM(0.05); } } if(oneosw==1) if(oneoscolorsw==1){ drawColoroneosculating(dg); }else{ drawoneosculating(dg); } if(oneoffsw){ if(!Rating[6]){ if(oneoffcolorsw==1){ drawColoroneoffset(dg); }else{ drawoneoffset(dg); } }else{ mycurve.changePARAM(deforePARAM); if(oneoffcolorsw==1){ drawColoroneoffset(dg); }else{ drawoneoffset(dg); } mycurve.changePARAM(0.05); } } if(onensw) if(onencolorsw==1){ drawColoronenormal(dg); }else{ drawonenormal(dg); } if(nsw==1){ if(!Rating[0]){ drawnormal(dg); }else{ mycurve.changePARAM(deforePARAM); drawnormal(dg); mycurve.changePARAM(0.05); } } if(tsw==1){ if(!Rating[2]){ drawtangent(dg); }else{ mycurve.changePARAM(deforePARAM); drawtangent(dg); mycurve.changePARAM(0.05); } } if(csw==1){ if(!Rating[1]){ drawCurvature(dg); }else{ mycurve.changePARAM(deforePARAM); drawCurvature(dg); mycurve.changePARAM(0.05); } } if(curvev==1) if(cvcolorsw==1){ this.drawColorbspline(dg); }else{ this.drawbspline(dg); } mycurve.changePARAM(deforePARAM); if(samplingvis==1){ mycurve.changePARAM(deforePARAM); if(virtualN != 160){ dg.setColor(teal); }else{ dg.setColor(Color.black); } this.drawbspline(dg); dg.setColor(Color.black); } } if(drawcontrolp==1&&mycurve.numberofpoint>=1){ Knot now = mycurve.Head; DoubleVector dumnow; Color dummyC; while(Next(now)!=mycurve.Tail){ now = Next(now); dumnow = Reparametrization(now.x,now.y); dummyC = dg.getColor(); dg.setColor(now.mycolor); dg.fillArc((int)(dumnow.x - 0.05*mycurve.scale), (int)(dumnow.y - 0.05*mycurve.scale), (int)(0.1*mycurve.scale),(int)(0.1*mycurve.scale),0,360); dg.setColor(dummyC); } } } public Image getImage(){ /* RETURN IMAGE */ Image savei = createImage(dd.width,dd.height); if (savei != null) mydg = savei.getGraphics(); if (savei != null) mydg.drawImage(savei, 0, 0, null); //mycurve.PARAM = 0.05; mydraw(mydg); return savei; //.dispose(); } public void mydraw(Graphics g ){ Dimension d = new Dimension(); d.width = dd.width -10; d.height = dd.height - 90; double nx; double ny; g.setColor(Color.white); g.fillRect(0,0,dd.width,dd.height); g.setColor(Color.black); double deforePARAM = mycurve.PARAM; if(mycurve.numberofpoint>=5){ mycurve.changePARAM(0.05); if(orsw==1){ if(!Rating[10]){ if(orcolorsw==1){ this.drawColorOrthotomic(g); }else{ this.drawOrthotomic(g); } }else{ mycurve.changePARAM(deforePARAM); if(orcolorsw==1){ this.drawColorOrthotomic(g); }else{ this.drawOrthotomic(g); } mycurve.changePARAM(0.05); } } if(norsw==1){ if(!Rating[11]){ if(norcolorsw==1){ this.drawColorFNOrthotomic(g); }else{ this.drawFNOrthotomic(g); } }else{ mycurve.changePARAM(deforePARAM); if(norcolorsw==1){ this.drawColorFNOrthotomic(g); }else{ this.drawFNOrthotomic(g); } mycurve.changePARAM(0.05); } } if(casw==1){ if(!Rating[12]){ if(cacolorsw==1){ this.drawColorCaustic(g); }else{ this.drawCaustic(g); } }else{ mycurve.changePARAM(deforePARAM); if(cacolorsw==1){ this.drawColorCaustic(g); }else{ this.drawCaustic(g); } mycurve.changePARAM(0.05); } } if((casw==1)||(norsw==1)||(orsw==1)){ g.setColor(Color.red); DoubleVector dumlight = Reparametrization(LightSource.x,LightSource.y); g.fillArc((int)(dumlight.x - 0.1*mycurve.scale), (int)(dumlight.y - 0.1*mycurve.scale), (int)(0.2*mycurve.scale),(int)(0.2*mycurve.scale),0,360); g.setColor(Color.black); } if(contourmap) this.drawContour(g); if(laplace) this.drawLaplace(g); if(cdriven1) this.drawCDriven(g); if(cdriven2) this.drawCDriven2(g); if(skeleton1){ if(!Rating[13]){ this.drawSkeleton1(g); }else{ mycurve.changePARAM(deforePARAM); this.drawSkeleton1(g); mycurve.changePARAM(0.05); } } if(voronoid){ if(!Rating[15]){ this.drawVoronoi(g); }else{ mycurve.changePARAM(deforePARAM); this.drawVoronoi(g); mycurve.changePARAM(0.05); } } if(skeleton2){ if(!Rating[14]){ this.drawSkeleton2(g); }else{ mycurve.changePARAM(deforePARAM); this.drawSkeleton2(g); mycurve.changePARAM(0.05); } } if(fnsw==1){ if(!Rating[7]){ if(fncolorsw==1){ this.drawColorenvelop(g); }else{ this.drawenvelop(g); } }else{ mycurve.changePARAM(deforePARAM); if(fncolorsw==1){ this.drawColorenvelop(g); }else{ this.drawenvelop(g); } mycurve.changePARAM(0.05); } } if(esw==1){ if(!Rating[9]){ if(evcolorsw==1){ this.drawColorEvolute(g); }else{ this.drawEvolute(g); } }else{ mycurve.changePARAM(deforePARAM); if(evcolorsw==1){ this.drawColorEvolute(g); }else{ this.drawEvolute(g); } mycurve.changePARAM(0.05); } } if(ofsw==1){ if(!Rating[5]){ if(ofcolorsw==1){ this.drawColoroffset(g); }else{ this.drawoffset(g); } }else{ mycurve.changePARAM(deforePARAM); if(ofcolorsw==1){ this.drawColoroffset(g); }else{ this.drawoffset(g); } mycurve.changePARAM(0.05); } } if(osw==1){ if(!Rating[3]){ if(oscolorsw==1){ drawColorosculating(g); }else{ drawosculating(g); } }else{ mycurve.changePARAM(deforePARAM); if(oscolorsw==1){ drawColorosculating(g); }else{ drawosculating(g); } mycurve.changePARAM(0.05); } } if(oneosw==1) if(oneoscolorsw==1){ drawColoroneosculating(g); }else{ drawoneosculating(g); } if(oneoffsw){ if(!Rating[6]){ if(oneoffcolorsw==1){ drawColoroneoffset(g); }else{ drawoneoffset(g); } }else{ mycurve.changePARAM(deforePARAM); if(oneoffcolorsw==1){ drawColoroneoffset(g); }else{ drawoneoffset(g); } mycurve.changePARAM(0.05); } } if(onensw) if(onencolorsw==1){ drawColoronenormal(g); }else{ drawonenormal(g); } if(nsw==1){ if(!Rating[0]){ drawnormal(g); }else{ mycurve.changePARAM(deforePARAM); drawnormal(g); mycurve.changePARAM(0.05); } } if(tsw==1){ if(!Rating[2]){ drawtangent(g); }else{ mycurve.changePARAM(deforePARAM); drawtangent(g); mycurve.changePARAM(0.05); } } if(csw==1){ if(!Rating[1]){ drawCurvature(g); }else{ mycurve.changePARAM(deforePARAM); drawCurvature(g); mycurve.changePARAM(0.05); } } if(curvev==1) if(cvcolorsw==1){ this.drawColorbspline(g); }else{ this.drawbspline(g); } mycurve.changePARAM(deforePARAM); if(samplingvis==1){ mycurve.changePARAM(deforePARAM); if(virtualN != 160){ g.setColor(teal); }else{ g.setColor(Color.black); } this.drawbspline(g); g.setColor(Color.black); } } if(drawcontrolp==1&&mycurve.numberofpoint>=1){ Knot now = mycurve.Head; DoubleVector dumnow; Color dummyC; while(Next(now)!=mycurve.Tail){ now = Next(now); dumnow = Reparametrization(now.x,now.y); dummyC = g.getColor(); g.setColor(now.mycolor); g.fillArc((int)(dumnow.x - 0.05*mycurve.scale), (int)(dumnow.y - 0.05*mycurve.scale), (int)(0.1*mycurve.scale),(int)(0.1*mycurve.scale),0,360); g.setColor(dummyC); } } } public void drawbspline(Graphics myg){ DoubleVector dnowummy,dumnow,ddnowummy,dumn; boolean checkfirst=true; for(double t = 0.0; t<=((double)(mycurve.numberofpoint));t+=mycurve.PARAM){ if(t>((double)(mycurve.numberofpoint))) t = ((double)(mycurve.numberofpoint)); dnowummy = mycurve.getPoint(t); dumnow = Reparametrization(dnowummy.x,dnowummy.y); ddnowummy = mycurve.getPoint((t+mycurve.PARAM)); dumn = Reparametrization(ddnowummy.x,ddnowummy.y); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumn.x),(int)(dumn.y)); if(checkfirst){ checkfirst = false; t+=0.0000001; } } myg.setColor(Color.black); } public void drawColorbspline(Graphics myg){ float h=((float)(0.0)); DoubleVector dnowummy,dumnow,ddnowummy,dumn; for(double t = 0.0; t<=((double)(mycurve.numberofpoint));t+=mycurve.PARAM){ h = (float)(t/((float)(mycurve.numberofpoint))); myg.setColor(Color.getHSBColor(h,(float)(1.0),(float)(0.9))); dnowummy = mycurve.getPoint(t); dumnow = Reparametrization(dnowummy.x,dnowummy.y); ddnowummy = mycurve.getPoint((t+mycurve.PARAM)); dumn = Reparametrization(ddnowummy.x,ddnowummy.y); myg.drawLine((int)(dumnow.x),(int)(dumnow.y), (int)(dumn.x),(int)(dumn.y)); } myg.setColor(Color.black); } /* public void run() { while(true){ try{ Thread.sleep(10); }catch(InterruptedException e){ System.out.println("run error!"); System.exit(0); } System.out.println("AAA"); this.repaint(); } } public void destroy() { System.out.println("destroy thread"); thread.stop(); }*/ public void paint(Graphics g) { try{ draw(g); g.drawImage(double_buffer,0,0,this); }catch(java.lang.NullPointerException e) { System.out.println("NullPointerException in paint !!!"); } } public void renewalpaint() { dummyg = this.getGraphics(); try{ drawR(dummyg); dummyg.drawImage(double_buffer,0,0,this); }catch(java.lang.NullPointerException e) { System.out.println("NullPointerException in renewalpaint !!!"); } dummyg.dispose(); } public void update(Graphics g) { paint(g); } public void focusGained(FocusEvent e) { repaint(); } public void mouseClicked(MouseEvent e){} public void mousePressed(MouseEvent e){ defc = this.getCursor(); double nx; double ny; DoubleVector mousein; if((freemovesw==0)&&(freescalesw==0)){ mousein = InReparametrization((double)(e.getX()),(double)(e.getY())); nx = mousein.x; ny = mousein.y; Knot dummytarget; if(drawcontrolp==1){ dummytarget = mycurve.CatchPoint(new DoubleVector(nx,ny)); }else{ dummytarget = new Knot(0.0,0.0); dummytarget.error = 1; } if(dummytarget.error!=1){ /* Catch control point */ //this.setCursor(new Cursor(Cursor.HAND_CURSOR)); target = mycurve.CatchPoint(new DoubleVector(nx,ny)); }else{ DoubleVector dumlight = new DoubleVector(LightSource.x,LightSource.y); if(Math.sqrt(((nx-dumlight.x)*(nx-dumlight.x) + (ny-dumlight.y)*(ny-dumlight.y)))<=0.15){ /* Catch Light Source point */ if((casw==1)||(norsw==1)||(orsw==1)){ //this.setCursor(new Cursor(Cursor.HAND_CURSOR)); LightSource.error = 0; target = LightSource; } }else{ if(oneosw==1){ DoubleVector dumosc = new DoubleVector(OscPoint.x,OscPoint.y); if(Math.sqrt(((nx-dumosc.x)*(nx-dumosc.x) + (ny-dumosc.y)*(ny-dumosc.y)))<=0.15){ /* Catch Moving Osculating point */ //this.setCursor(new Cursor(Cursor.HAND_CURSOR)); OscPoint.error = 0; target = OscPoint; backtarget = new Knot(nx,ny); } } if(onensw){ DoubleVector dumnor = new DoubleVector(NorPoint.x,NorPoint.y); //System.out.println("Moving Normal"); if(Math.sqrt(((nx-dumnor.x)*(nx-dumnor.x) + (ny-dumnor.y)*(ny-dumnor.y)))<=0.15){ /* Catch Moving Normal point */ //this.setCursor(new Cursor(Cursor.HAND_CURSOR)); //System.out.println("Catch Moving Normal"); NorPoint.error = 0; target = NorPoint; backtarget = new Knot(nx,ny); } } if(oneoffsw){ DoubleVector dumoff = new DoubleVector(OffPoint.x,OffPoint.y); if(Math.sqrt(((nx-dumoff.x)*(nx-dumoff.x) + (ny-dumoff.y)*(ny-dumoff.y)))<=0.15){ /* Catch Moving Offset point */ //this.setCursor(new Cursor(Cursor.HAND_CURSOR)); OffPoint.error = 0; target = OffPoint; backtarget = new Knot(nx,ny); } } if(skeleton1&&skeleton1movin){ DoubleVector dumske = new DoubleVector(SkePoint.x,SkePoint.y); if(Math.sqrt(((nx-dumske.x)*(nx-dumske.x) + (ny-dumske.y)*(ny-dumske.y)))<=0.15){ /* Catch Moving Skeleton point */ //this.setCursor(new Cursor(Cursor.HAND_CURSOR)); SkePoint.error = 0; target = SkePoint; backtarget = new Knot(nx,ny); } } } } repaint(); }else{ nx = (double)(xrv(e.getX())); ny = (double)(yrv(e.getY())); backtarget = new Knot(nx,ny); repaint(); } } public void mouseReleased(MouseEvent e){ //this.setCursor(defc); target = NULL; LightSource.error = 1; oscdvsw=0; skedvsw=0; offdvsw=0; nordvsw=0; OscPoint.error = 1; SkePoint.error = 1; OffPoint.error = 1; NorPoint.error = 1; backtarget = NULL; repaint(); } public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseDragged(MouseEvent e) { double nx; double ny; DoubleVector mousein; if((freemovesw==0)&&(freescalesw==0)){ if(target!=NULL) if((((0=0.0)&&(angledvt<=(Math.PI/2.0))){ if(paramosc>=((double)((mycurve).numberofpoint))){ paramosc=0.0; }else{ if(!Rating[4]){ paramosc += 0.05; }else{ paramosc += ((double)(mycurve.PARAM)); } } }else{ if(paramosc<=0.0){ paramosc =((double)((mycurve).numberofpoint)); }else{ if(!Rating[4]){ paramosc -= 0.05; }else{ paramosc -= ((double)(mycurve.PARAM)); } } } backtarget = new Knot(nx,ny); } }else if(NorPoint.error==0){ /* Move Moving Normal point */ if(nordvsw==0){ nordvsw=1; backtarget = new Knot(nx,ny); }else{ DoubleVector tangent = mycurve.getTangent(paramnor); DoubleVector dv = Normalize(new DoubleVector((nx - backtarget.x), (ny - backtarget.y))); double angledvt = CosineAngle(dv,tangent); if((angledvt>=0.0)&&(angledvt<=(Math.PI/2.0))){ if(paramnor>=((double)((mycurve).numberofpoint))){ paramnor=0.0; }else{ if(!Rating[8]){ paramnor += 0.05; }else{ paramnor += ((double)(mycurve.PARAM)); } } }else{ if(paramnor<=0.0){ paramnor =((double)((mycurve).numberofpoint)); }else{ if(!Rating[8]){ paramnor -= 0.05; }else{ paramnor -= ((double)(mycurve.PARAM)); } } } backtarget = new Knot(nx,ny); } }else if(OffPoint.error==0){ /* Move Moving Offset point */ if(offdvsw==0){ offdvsw=1; backtarget = new Knot(nx,ny); }else{ DoubleVector tangent = mycurve.getTangent(paramoff); DoubleVector dv = Normalize(new DoubleVector((nx - backtarget.x), (ny - backtarget.y))); double angledvt = CosineAngle(dv,tangent); if((angledvt>=0.0)&&(angledvt<=(Math.PI/2.0))){ if(paramoff>=((double)((mycurve).numberofpoint))){ paramoff=0.0; }else{ paramoff += 0.05; } if(offparam>=800.0){ offparam=800.0; }else{ offparam+=5.0; } }else{ if(paramoff<=0.0){ paramoff =((double)((mycurve).numberofpoint)); }else{ paramoff -= 0.05; } if(offparam<=-800.0){ offparam=-800.0; }else{ offparam-=5.0; } } backtarget = new Knot(nx,ny); } }else if(SkePoint.error==0){ /* Move Moving Skeleton point */ if(skedvsw==0){ skedvsw=1; backtarget = new Knot(nx,ny); }else{ DoubleVector tangent = new DoubleVector(Skeleton_Buffer2[paramske].tangent.x, Skeleton_Buffer2[paramske].tangent.y); DoubleVector dv = Normalize(new DoubleVector((nx - backtarget.x), (ny - backtarget.y))); double angledvt = CosineAngle(dv,tangent); if((angledvt>=0.0)&&(angledvt<=(Math.PI/2.0))){ if(paramske>=numberofSkeleton_Buffer2-1){ paramske=0; }else{ paramske++; } }else{ if(paramske<=0){ paramske = numberofSkeleton_Buffer2-1; }else{ paramske--; } } backtarget = new Knot(nx,ny); } }else{ /* Move Control point or Light Source point */ target.x = nx; target.y = ny; } if((LightSource.error == 1)&&(OscPoint.error==1)&&(SkePoint.error==1) &&(NorPoint.error==1)&&(OffPoint.error==1)){ mycurve.setInitControlPs(); /* if(skeleton2) makeSkeleton2(); if(skeleton1) makeSkeleton1(); if(voronoid) makeVoronoi(); if(laplace) makeLaplace(); if(cdriven1) makeCDriven(); if(cdriven2) makeCDriven2(); if(contourmap) makeContour(); */ renewalpaint(); }else{ repaint(); } } }else{ nx = (double)(xrv(e.getX())); ny = (double)(yrv(e.getY())); int dx = (int)(nx - backtarget.x); int dy = (int)(ny - backtarget.y); if(freescalesw==1){ if(dx>0.0){ //scale += 0.05; mycurve.scale += 5.0; }else{ //scale -= 0.05; mycurve.scale -= 5.0; } if(mycurve.scale<=5){ mycurve.scale = 5.0; }else if(mycurve.scale>=1000.0){ mycurve.scale = 1000.0; } if(scale < 0.1){ scale = 0.1; }else if(scale > 10.0){ scale = 10.0 ; } }else{ if((Center.x + dx)>600){ Center.x = 600; scrX.setValue(600); }else if((Center.x + dx)< -600){ Center.x = -600; scrX.setValue(-600); }else{ Center.x += dx; scrX.setValue(((int)(Center.x))); } if((Center.y + dy)>600){ Center.y = 600; scrY.setValue(600); }else if((Center.y + dy)< -600){ Center.y = -600; scrY.setValue(-600); }else{ Center.y += dy; scrY.setValue(((int)(Center.y))); } } //System.out.println("Projection Change "); repaint(); } } public void mouseMoved(MouseEvent e){} private Vertex next(Vertex now) { return (now.next); } private Vertex back(Vertex now) { return (now.back); } private Knot Next(Knot now) { return (now.next); } private Knot Back(Knot now) { return (now.back); } private DoubleVector getLap(DoubleVector backv,DoubleVector nowv,DoubleVector nextv){ DoubleVector d1 = Normalize(new DoubleVector((backv.x -nowv.x),(backv.y -nowv.y))); DoubleVector d2 = Normalize(new DoubleVector((nextv.x -nowv.x),(nextv.y -nowv.y))); return new DoubleVector((d1.x+d2.x),(d1.y+d2.y)); } private double ScalarP(DoubleVector dv1,DoubleVector dv2){ return ((double)(dv1.x*dv2.x + dv1.y*dv2.y)); } private double CosineAngle(DoubleVector dv1,DoubleVector dv2){ double sdv1,sdv2; sdv1 = Size(dv1); sdv2 = Size(dv2); if((sdv1==0.0)||(sdv2==0.0)){ return 0.0; }else{ return ((double)(Math.acos(ScalarP(dv1,dv2)/(sdv1*sdv2)))); } } private double Size(DoubleVector dv){ return ((double)(Math.sqrt((dv.x*dv.x + dv.y*dv.y)))); } private DoubleVector NewNormalize(DoubleVector in) { DoubleVector v = new DoubleVector(in.x,in.y); v.size = Math.sqrt((v.x)*(v.x)+(v.y)*(v.y)); if(v.size!=0){ v.x = (double)(v.x/v.size); v.y = (double)(v.y/v.size); v.size = 1.0; }else{ v.size = 0.0; } return v; } private DoubleVector Normalize(DoubleVector dv){ double ds,dx,dy; ds = Size(dv); if(ds==0.0)return dv; dx = (dv.x/ds); dy = (dv.y/ds); return new DoubleVector(dx,dy); } public DoubleVector Reparametrization(double dx,double dy){ double ddx,ddy; ddx = (Center.x + (double)((mycurve.scale)*(dx-4.0)) + 400.0); ddy = (Center.y +(double)(aread.height - ((double)((mycurve.scale)*(dy-2.0)) +200.0))); return new DoubleVector(ddx,ddy); } public DoubleVector InReparametrization(double dx,double dy){ double ddx,ddy; ddx = ((dx - (Center.x + 400.0))/mycurve.scale + 4.0); ddy = ((- dy + (Center.y + ((double)(aread.height))) - 200.0)/mycurve.scale + 2.0); return new DoubleVector(ddx,ddy); } private int xrv(int dx){ double dv = ((double)(dx) - 400.0) -Center.x + 400.0; return ((int)(dv)); } private int yrv(int dy){ double dv = ((double)(dy) -200.0) -Center.y + 200.0; return ((int)(dv)); } private double Distance(DoubleVector v1,DoubleVector v2) { DoubleVector v = new DoubleVector((v2.x-v1.x),(v2.y-v1.y)); return ((double)(Math.sqrt((v.x*v.x)+(v.y*v.y)))); } private double VectorSize(DoubleVector dv){ return Math.sqrt((dv.x*dv.x+dv.y*dv.y)); } public void SplitCP(){ if(skeleton2) makeSkeleton2(); if(skeleton1) makeSkeleton1(); if(voronoid) makeVoronoi(); if(laplace) makeLaplace(); if(cdriven1) makeCDriven(); if(cdriven2) makeCDriven2(); if(contourmap) makeContour(); paramosc=0.0; paramske=0; paramoff=0.0; offparam=0.0; paramnor=0.0; this.repaint(); } public void CollapseCP(){ if(skeleton2) makeSkeleton2(); if(skeleton1) makeSkeleton1(); if(voronoid) makeVoronoi(); if(laplace) makeLaplace(); if(cdriven1) makeCDriven(); if(cdriven2) makeCDriven2(); if(contourmap) makeContour(); paramosc=0.0; paramske=0; paramoff=0.0; offparam=0.0; paramnor=0.0; this.repaint(); } }