Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Tetrahedron.java
- // Easel
- //
- // Created by Philip Rhodes on 8/2/05.
- // Copyright 2005 Philip J Rhodes. All rights reserved.
- //
- /*
- * This class represents a tetredron. It is placed on the zero plane
- * with its top vertex on the y axis. On the base, two points are placed
- * symmetrically on either side of the positive z axis, and the third
- * point is placed behind, on the negative z axis.
- */
- public class Tetrahedron extends Shape{
- public Tetrahedron(float size){
- // This shape needs 4 vertices and 4 triangles.
- super(4, 4);
- this.setScales(size, size, size);
- float d = (float) (1/(2*Math.cos(Math.PI/6)));
- setVertex(0, 0, (float) Math.sqrt(1-d*d), 0);
- setVertex(1, 0, 0, -d);
- setVertex(2, 0.5f, 0, (float) Math.tan(Math.PI/6)/2);
- setVertex(3, -0.5f, 0, (float) Math.tan(Math.PI/6)/2);
- // CCW Winding Order
- setTriangle(0, 1, 2, 3);
- setTriangle(1, 0, 2, 1);
- setTriangle(2, 0, 1, 3);
- setTriangle(3, 0, 3, 2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement