import java.awt.*; import javax.swing.*; import java.awt.Graphics2D; import java.awt.geom.*; /** * Draws two colored triangles and illuminates them with one source. * Simple, with hard-coded parameters. * Uses GeneralPath to draw the triangles, after removing z coordinates. * * @author Bob Futrelle * @version 0.1 15 July 2003 * First triangle has corners at 50 on each of the x,y and z axes. * Color is greenish, 0.1, 0.1, 0.1 * Second one is in the x,y plane, corners at origin and 50 on x and y. * Color is reddish, 1.0, 0.1, 0.1 * Light source is along the z axis. * Light color is primarily red, 1.0, 0.5, 0.5. * */ class IllumPanel extends JPanel { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; } /** * Inner class for simple 3D colored triangle. */ class Triangle { Vec3D v1, v2, v3; Color color; Triangle(Vec3D v1, Vec3D v2, Vec3D v3, Color c) { this.v1=v1; this.v2=v2; this.v3=v3; color = c; } /** Uses cross product */ Vec3D getNormal() { Vec3D edge1 = Vec3D.diff(v2,v1); Vec3D edge2 = Vec3D.diff(v3,v2); Vec3D normal = Vec3D.crossProd(edge2,edge1); } } // class Triangle /** * Inner class for 3D vector and operations */ class Vec3D { double[] vec; void printVec() { DecimalFormat threePlaces = new DecimalFormat( "0.000"); for(int p=0, return fourPlaces.format(matrix[0][0]) + " " + } // printVec() } // class Vec3D } // class SDDrawer