Class Triangle

java.lang.Object
  extended byTriangle

public class Triangle
extends java.lang.Object

A triangle in 3D, with three Vec vertices and a reflectivity (a Color). A triangle is represented by the Vec objects of its three vertices. A triangle has a color associated with it, for filling, illumination, etc.

For CSU540 Computer Graphics class, Spring 2005 CCIS, Northeastern University

Includes linear transform using a Mat
Method names ending with "Same" alter the given triangle. Others return a copy.

Version:
26 January 2005
Author:
Bob Futrelle

Field Summary
 java.awt.Color color
          Color, for filling, illumination, etc.
 Vec normal
          The unit outward normal
 Vec[] tri
          The three vertices
 
Constructor Summary
Triangle()
          Creates black Triangle with the 3-element Vec array.
Triangle(Vec v0, Vec v1, Vec v2, java.awt.Color c)
          Creates colored Triangle with the three given vertices
 
Method Summary
 void drawTri(java.awt.Graphics g)
          Creates and closes a GeneralPath for the triangle, sets the color and fills it.
static void main(java.lang.String[] args)
          Tests and prints results of all methods (all are static)
 Vec normalToTriangle()
          Finds the unit normal to a triangle.
 java.lang.String toString()
          Lists the three vertices
static Triangle transformTriangle(Mat mat, Triangle t1)
          Produces a copy of the triangle after a linear transform is applied.
 void transformTriangleSame(Mat mat)
          Alters this triangle by applying a linear transform is applied.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tri

public Vec[] tri
The three vertices


normal

public Vec normal
The unit outward normal


color

public java.awt.Color color
Color, for filling, illumination, etc.

Constructor Detail

Triangle

public Triangle()
Creates black Triangle with the 3-element Vec array.


Triangle

public Triangle(Vec v0,
                Vec v1,
                Vec v2,
                java.awt.Color c)
Creates colored Triangle with the three given vertices

Method Detail

main

public static void main(java.lang.String[] args)
Tests and prints results of all methods (all are static)


toString

public java.lang.String toString()
Lists the three vertices


transformTriangle

public static Triangle transformTriangle(Mat mat,
                                         Triangle t1)
Produces a copy of the triangle after a linear transform is applied.
TO BE COMPLETED:
THIS SHOULD NOT BE A STATIC METHOD. CHANGE IT.

Parameters:
mat - The linear transform.
t1 - The triangle to be transformed.
Returns:
A new triangle which has the transformed vertices.

transformTriangleSame

public void transformTriangleSame(Mat mat)
Alters this triangle by applying a linear transform is applied.
TO BE COMPLETED:

Parameters:
mat - The linear transform.

normalToTriangle

public Vec normalToTriangle()
Finds the unit normal to a triangle. The perimeter is traversed in order v0, v1, v2. Sets the normal field of Triangle.
TO BE COMPLETED


drawTri

public void drawTri(java.awt.Graphics g)
Creates and closes a GeneralPath for the triangle, sets the color and fills it.