ProGAL.geom3d
Class Triangle

java.lang.Object
  extended by ProGAL.geom3d.Triangle
All Implemented Interfaces:
Shape, Simplex
Direct Known Subclasses:
CTriangle

public class Triangle
extends java.lang.Object
implements Simplex

A triangle in (x,y,z)-space represented by the three corner-points.


Constructor Summary
Triangle(Point[] p)
           
Triangle(Point p1, Point p2, Point p3)
          Construct a triangle using the three specified points as corners
 
Method Summary
 Point circumcenter()
          Return the circumcenter of the triangle.
 double circumradius()
          Return the circumradius of the triangle.
 Triangle clone()
           
 boolean contains(Point p)
           
 double getArea()
          Return the area of one side of the triangle.
 Point getCenter()
          Return the center of the triangle.
 Point getCorner(int c)
          Get the specified corner of this triangle
 int getDimension()
          Return the 'dimension' of this object.
 Point getIntersection(Point p, Vector dir)
           
 Vector getNormal()
          Return a vector that is normal to this triangle.
 Point getP1()
          Get the first corner
 Point getP2()
          Get the second corner
 Point getP3()
          Get the third corner
 Point getPoint(int c)
          Get the specified corner-point of this triangle
 Point incenter()
           
 double inradius()
           
 void toConsole()
          Writes this triangle to System.out with 2 decimals precision.
 void toConsole(int dec)
          Writes this triangle to System.out with dec decimals precision.
 Tetrahedron toScene(J3DScene scene, java.awt.Color clr)
           
 java.lang.String toString()
          Returns a string-representation of this triangle formatted with two decimals precision.
 java.lang.String toString(int dec)
          Returns a string-representation of this triangle formatted with dec decimals precision.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Triangle

public Triangle(Point p1,
                Point p2,
                Point p3)
Construct a triangle using the three specified points as corners


Triangle

public Triangle(Point[] p)
Method Detail

getP1

public Point getP1()
Get the first corner


getP2

public Point getP2()
Get the second corner


getP3

public Point getP3()
Get the third corner


getCorner

public Point getCorner(int c)
Get the specified corner of this triangle


getPoint

public Point getPoint(int c)
Get the specified corner-point of this triangle

Specified by:
getPoint in interface Simplex

getDimension

public int getDimension()
Return the 'dimension' of this object. Required by the interface Simplex.

Specified by:
getDimension in interface Simplex

getCenter

public Point getCenter()
Return the center of the triangle. Here average of the corners is used.

Specified by:
getCenter in interface Shape

getArea

public double getArea()
Return the area of one side of the triangle.


getNormal

public Vector getNormal()
Return a vector that is normal to this triangle.


circumradius

public double circumradius()
Return the circumradius of the triangle. If one side has zero length this method returns the length of the two remaining sides.


circumcenter

public Point circumcenter()
Return the circumcenter of the triangle. TODO: Test TODO: Make more efficient (transform to origo with n as z and use 2D formula)


inradius

public double inradius()

incenter

public Point incenter()

getIntersection

public Point getIntersection(Point p,
                             Vector dir)

contains

public boolean contains(Point p)

toString

public java.lang.String toString()
Returns a string-representation of this triangle formatted with two decimals precision.

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(int dec)
Returns a string-representation of this triangle formatted with dec decimals precision.


toConsole

public void toConsole()
Writes this triangle to System.out with 2 decimals precision.


toConsole

public void toConsole(int dec)
Writes this triangle to System.out with dec decimals precision.


toScene

public Tetrahedron toScene(J3DScene scene,
                           java.awt.Color clr)

clone

public Triangle clone()
Overrides:
clone in class java.lang.Object