Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the Cube class without using gpt: Instructions Follow the instructions below for each class. Point.java This class represents a point in 3 dimensional Cartesian

Write the Cube class without using gpt:
Instructions
Follow the instructions below for each class.
Point.java
This class represents a point in 3 dimensional Cartesian space.
Fields
Field Name
Type
Access Modifier
Description
x
double
private
The x coordinate in Cartesian space
y
double
private
The y coordinate in Cartesian space
z
double
private
The z coordinate in Cartesian space
Constructor
Access Modifier
Constructor Name
Input Parameters
Description
public
Point
double x,
double y,
double z
Construct a newly allocated Point object and instantiate the fields to their respective parameters.
public
Point
None
Construct a newly allocated Point object and instantiate all fields set to 0.0.
Methods
Method Name
Return Type
Access Modifier
Input Parameters
Description
getX
double
public
none
Returns the x value of this Point.
getY
double
public
none
Returns the y value of this Point.
getZ
double
public
none
Returns the z value of this Point.
setX
void
public
double x
Sets the x value of this Point
setY
void
public
double y
Sets the y value of this Point
setZ
void
public
double z
Sets the z value of this Point
compareTo
boolean
public
Point point
Compares this Point to point. Return true if the Points are equal. For this assignment double variables are considered equal if they are within +/-0.0001 precision of each other, see note at the end. Otherwise return false.
toString
String
public
None
Returns the String representation of this Point.
For Example, given the following fields:
x =1.000
y =2.000
z =0.000
The result of calling toString() would be:
(x1.000, y2.000, z0.000)
Note the returned String should be formatted to EXACTLY 3 decimal places.
UnitVector.java
This class represents a Unit Vector in 3 dimensional Cartesian space. A unit vector is a direction with magnitude 1.
Fields
Field Name
Type
Access Modifier
Description
i
double
private
the i component of a vector in 3D space
j
double
private
The j component of a vector in 3D space
k
double
private
The z component of a vector in 3D space
Constructors:
Access Modifier
Constructor Name
Input Parameters
Description
public
UnitVector
double i,
double j,
double k
Construct a newly allocated UnitVector object and instantiate the fields to the specified parameters.
Confirm that the magnitude of the UnitVector is equal to 1.000. For this assignment double variables are considered equal if they are within +/-0.0001 precision of each other, see note at the end.
Magnitude=\sqrt{i^{2}+j^{2}+k^{2}}
If the value is not equal to 1.000 then scale the vector by its magnitude with the following series of equations:
i=\frac{i}{Magnitude}
j=\frac{j}{Magnitude}
k=\frac{k}{Magnitude}
Note: in the case where the magnitude is equal to 0 all fields should be initialized to 0.000.
public
UnitVector
Point start,
Point end
Construct a newly allocated UnitVector object from the two given points using the following equation:
i = end.x - start.x
j = end.y - start.y
k = end.z - start.z
Confirm that the magnitude of the UnitVector is equal to 1.000. For this assignment double variables are considered equal if they are within +/-0.0001 precision of each other, see note at the end.
Magnitude=\sqrt{i^{2}+j^{2}+k^{2}}
If the value is not equal to 1.000 then scale the vector by its magnitude with the following series of equations:
i=\frac{i}{Magnitude}
j=\frac{j}{Magnitude}
k=\frac{k}{Magnitude}
Note: in the case where the magnitude is equal to 0 all fields should be initialized to 0.000.
public
UnitVector
none
Construct a newly allocated UnitVector object with all fields instantiated to 0.000.(An invalid vector)
Methods:
Method Name
Return Type
Access Modifier
Input
Parameters
Description
getI
note: 'I' is a capital 'i'
double
public
None
Returns the i value of this UnitVector
getJ
double
public
None
Returns the j value of this UnitVector
getK
double
public
None
Returns the k value of this UnitVector
flipVector
void
public
None
Changes the direction of this UnitVector to be the inverse.
i =-i, j =-j, and k =-k
compareTo
boolean
public
UnitVector vector
Compares this UnitVector to vector. Return true if the UnitVectors are equal. For this assignment double variables are considered equal if they are within +/-0.0001 precision of each other, see note at the end. Otherwise return false.
crossProduct
UnitVector
public
UnitVector b
Returns a newly allocated UnitVector object with fields set by the following equations:
i=this.j*b.k-this.k*b.j
j=this.k*b.i-this.i*b.k
k=this.i*b.j-this.j*b.i
Confirm that the magnitude of the UnitVector is equal to 1.000. For this assignment double variables are considered equal if they are within +/-0.0001 precision of each other, see note at the end.
Magnitude=\sqrt{i^{2}+j^{2}+k^{2}}
If the value is not equal to 1.000 then scale the vector by its magnitude with the following series of equations:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

4. Describe cultural differences that influence perception

Answered: 1 week ago