[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Vertex.java, 1.36, 1.37 Line.java, 1
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-07-12 12:08:37
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv20690/src/net/sourceforge/bprocessor/model Modified Files: Vertex.java Line.java Log Message: changed the construction of Line from degrees to a direction vertex and added normalize to vertex Index: Vertex.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Vertex.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Vertex.java 6 Jul 2006 13:13:53 -0000 1.36 --- Vertex.java 12 Jul 2006 12:08:35 -0000 1.37 *************** *** 413,415 **** --- 413,424 ---- getOwner().delete(this); } + + /** + * Make the length of the vertex equal one + */ + public void normalize() { + if (getX() != 0.0 || getY() != 0.0 || getZ() != 0.0) { + this.scale(1 / this.length()); + } + } } Index: Line.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Line.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Line.java 7 Jul 2006 10:46:03 -0000 1.5 --- Line.java 12 Jul 2006 12:08:35 -0000 1.6 *************** *** 16,35 **** */ public class Line extends Constructor { ! /** The rotation of the x - axis (arround the y axis) */ ! private int degreeX; ! /** The rotation of the y - axis (arround the z axis) */ ! private int degreeY; ! /** The rotation of the z - axis (arround the x axis) */ ! private int degreeZ; /** ! * Constuctor of Line with only the origin * @param origin The origin */ public Line(Vertex origin) { super(origin); ! this.degreeX = 0; ! this.degreeY = 0; ! this.degreeZ = 0; } --- 16,29 ---- */ public class Line extends Constructor { ! /** The direction vector */ ! private Vertex dir; /** ! * Constuctor of Line with only the origin and a standard direction of (1,0,0) * @param origin The origin */ public Line(Vertex origin) { super(origin); ! dir = new Vertex(1, 0, 0); } *************** *** 37,49 **** * Constructor of the Line with orgin and three angles * @param origin The origin ! * @param degreeX The angle around the X axis ! * @param degreeY The angle around the Y axis ! * @param degreeZ The angle around the Z axis */ ! public Line(Vertex origin, int degreeX, int degreeY, int degreeZ) { super(origin); ! this.degreeX = degreeX; ! this.degreeY = degreeY; ! this.degreeZ = degreeZ; } --- 31,40 ---- * Constructor of the Line with orgin and three angles * @param origin The origin ! * @param dir The vector of direction */ ! public Line(Vertex origin, Vertex dir) { super(origin); ! dir.normalize(); ! this.dir = dir; } *************** *** 53,60 **** */ public Vertex getDirection() { - Vertex dir = new Vertex(Math.cos(Math.toRadians(degreeX)), - Math.sin(Math.toRadians(degreeY)), - Math.sin(Math.toRadians(degreeZ))); - dir.scale(1 / dir.length()); return dir; } --- 44,47 ---- *************** *** 86,130 **** /** ! * @return Returns the degreeX. ! */ ! public int getDegreeX() { ! return degreeX; ! } ! ! /** ! * @param degreeX The degreeX to set. ! */ ! public void setDegreeX(int degreeX) { ! this.degreeX = degreeX; ! } ! ! /** ! * @return Returns the degreeY. ! */ ! public int getDegreeY() { ! return degreeY; ! } ! ! /** ! * @param degreeY The degreeY to set. */ ! public void setDegreeY(int degreeY) { ! this.degreeY = degreeY; } ! /** ! * @return Returns the degreeZ. */ ! public int getDegreeZ() { ! return degreeZ; } ! /** ! * @param degreeZ The degreeZ to set. */ ! public void setDegreeZ(int degreeZ) { ! this.degreeZ = degreeZ; } ! /** * @see net.sourceforge.bprocessor.model.Parametric#setAttributes() --- 73,112 ---- /** ! * Overwrite the direction of the line ! * @param dir the vector direction */ ! public void setDirection(Vertex dir) { ! this.dir = dir; ! dir.normalize(); } ! /** ! * @return Returns the degrees in radian about the z-axis. */ ! public double degreesAboutZ() { ! Vertex tmp; ! if (dir.getX() != 0.0) { ! tmp = new Vertex(dir.getX(), dir.getY(), 0); ! } else { ! tmp = new Vertex(0, dir.getY(), dir.getZ()); ! } ! tmp.normalize(); ! return Math.acos(tmp.getX()); } ! /** ! * @return Returns the degrees in radian about the y-axis. */ ! public double degreesAboutY() { ! Vertex tmp; ! if (dir.getX() != 0.0) { ! tmp = new Vertex(dir.getX(), 0, dir.getZ()); ! } else { ! tmp = new Vertex(0, dir.getY(), dir.getZ()); ! } ! tmp.normalize(); ! return Math.asin(tmp.getZ()); } ! /** * @see net.sourceforge.bprocessor.model.Parametric#setAttributes() *************** *** 142,148 **** res.add(new Attribute("Origin", getOrigin())); ! res.add(new Attribute("Angle X", new Double(getDegreeX()))); ! res.add(new Attribute("Angle Y", new Double(getDegreeY()))); ! res.add(new Attribute("Angle Z", new Double(getDegreeZ()))); return res; } --- 124,128 ---- res.add(new Attribute("Origin", getOrigin())); ! res.add(new Attribute("Direction", getDirection())); return res; } *************** *** 160,165 **** */ public String toString() { ! return "Line: " + getOrigin() + " AngleX: " + getDegreeX() + ! " Angle Y: " + getDegreeY() + " Angle Z : " + getDegreeZ(); } } --- 140,144 ---- */ public String toString() { ! return "[Line: " + getOrigin() + " direction: " + getDirection() + "]"; } } |