Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27697/src/net/sourceforge/bprocessor/model
Modified Files:
Surface.java
Added Files:
Plane.java
Log Message:
Added a Plane class
Index: Surface.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Surface.java 22 Aug 2005 08:46:44 -0000 1.11
--- Surface.java 25 Aug 2005 14:32:37 -0000 1.12
***************
*** 132,136 ****
/**
! * returns the normal to this
* @return A vector normal for this surface, null if the surface consists of only one edge
*/
--- 132,136 ----
/**
! * Returns the normal to this
* @return A vector normal for this surface, null if the surface consists of only one edge
*/
***************
*** 154,157 ****
--- 154,176 ----
return null;
}
+
+ /**
+ * Returns the Plane that this Surface lies in
+ * @return The Plane for this Surface
+ */
+
+ Plane plane() {
+ double d = 0;
+ Vertex n = normal();
+ double l = n.length();
+ n.scale(1 / l);
+ double a = n.getX();
+ double b = n.getY();
+ double c = n.getZ();
+ Edge e1 = (Edge) edges.get(0);
+ Vertex v1 = e1.getFrom();
+ d = -(a * v1.getX() + b * v1.getY() + c * v1.getZ());
+ return new Plane(a, b, c, d);
+ }
/**
--- NEW FILE: Plane.java ---
//---------------------------------------------------------------------------------
// $Id: Plane.java,v 1.1 2005/08/25 14:32:37 henryml Exp $
//
// Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net)
// Released under the Lesser GNU Public License v2.1
//---------------------------------------------------------------------------------
package net.sourceforge.bprocessor.model;
/**
* The Plane
* A Plane is defined by the equation
* Ax + By + Cy + D = 0
*/
public class Plane {
/** The coefficient a */
private double a;
/** The coefficient b */
private double b;
/** The coefficient c */
private double c;
/** The coefficient d */
private double d;
/**
* Constructor
* @param a the a
* @param b the b
* @param c the c
* @param d the d
*/
public Plane(double a, double b, double c, double d) {
super();
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
/**
* Find the intersection with the ray (x y t)
* @param x the x
* @param y the y
* @return the intersection with the (x y t) ray
*/
double intersection(double x, double y) {
return 0;
}
}
|