Answered step by step
Verified Expert Solution
Question
1 Approved Answer
code these in java... Face.java This class represents a single face of a cube in 3 dimensional Cartesian space. ( A square ) A Square
code these in java... Face.java
This class represents a single face of a cube in dimensional Cartesian space. A square A Square is comprised of Triangles that share Vertices Points and have identical "Surface Normals" their UnitVectors point the same direction
Fields
Field Name
Type
Access Modifier
Description
mesh
Triangle
private
An array of Triangles that combine to make this Face a bounded square
surfaceNormal
UnitVector
private
The the surface normal of this Face.
Constructor
Access Modifier
Constructor Name
Input Parameters
Description
public
Face
Triangle one,
Triangle two,
If triangle one and two share two common vertices and their surface normals are equal. Construct a newly allocated Face object and instantiate the fields to their respective parameters. Triangle one should be index of mesh.
If the two triangles do not share at least two vertices or the surface normals are not equal then each triangle should be set to Triangle and the unit vector set to invalid all fields
public
Face
none
Construct a newly allocated Face object and instantiate the fields as follows: each triangle should be set to Triangle and the unit vector set to invalid all fields The face is invalid
Methods
Method Name
Return Type
Access Modifier
Input Parameters
Description
getMesh
Triangle
public
None
Returns the Triangle array that makes up the mesh of this Face.
getSurfaceNormal
UnitVector
public
None
Returns the UnitVector representing the surfaceNormal of this Face.
flipSurfaceNormal
void
public
None
Flips the direction of the Surface Normal of this Face, and all of its Triangles.
compareTo
boolean
public
Face face
Compares this Face to face. Return true if the Triangles share the same vertices and normal vectors. For this assignment double variables are considered equal if they are within precision of each other, see note at the end. Otherwise return false.
isSimilar
boolean
public
Face face
Compares this Face to face. Returns true if the triangles share the same vertices in any order OR have the same normal vectors. Otherwise return false.
toString
String
public
None
Returns the String representation of this Triangle.
For Example, given the following fields:
Triangle:
vertexAx y z
vertexBx y z
vertexCx y z
surfaceNormal ijk
Triangle:
vertexAx y z
vertexBx y z
vertexCx y z
surfaceNormal ijk
surfaceNormal ijk
The result of calling toString would be:
FAx y z; Bx y z; Cx y zAx y z; Bx y z; Cx y z Nijk
Note: The surface normal for the triangles are not printed, only the one for the face.
Note: This is one continuous string with no new line characters.
If any Triangle is invalid the result of toString should be:
InvalidFace
Cube.java
This class represents a Square in dimensional Cartesian space. A Cube is comprised of Faces squares where each face shares an edge has common vertices with other faces and faces that do not share an edge have opposite surface normal vectors One face has the inverse UnitVector of the other
Fields
Field Name
Type
Access Modifier
Description
mesh
Face
private
An array of Faces that make up the mesh of the Cube.
Constructor
Access Modifier
Constructor Name
Input Parameters
Description
public
Cube
Face one,
Face two,
Face three,
Face four,
Face five,
Face six
Construct a newly allocated Cube object and instantiate the fields to their respective parameters.
Confirm that each face shares exactly one edge with each of other faces. Confirm that no face is the same as another face. Confirm that each surfaceNormal of opposed Faces faces that do not share an edge is pointing in an opposite direction.
If any of the above is false, set each face in mesh to be an invalid face. all fields
Note: mesh should be instantiated to Face one and so on to mesh being Face six.
public
Cube
none
Construct a newly allocated Cube object and instantiate each Face in the mesh array to be invalid, all values are
Methods
Method Name
Return Type
Access Modifier
Input Parameters
Description
getMesh
Face
public
None
Returns the Face array representing the entire surface mesh of the Cube.
toString
String
public
None
Returns the String representation of this Cube.
The output should be in the format of:
C the toString of each face.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started