Answered step by step
Verified Expert Solution
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 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
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 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
y
z
The result of calling toString would be:
x y z
Note the returned String should be formatted to EXACTLY decimal places.
UnitVector.java
This class represents a Unit Vector in dimensional Cartesian space. A unit vector is a direction with magnitude
Fields
Field Name
Type
Access Modifier
Description
i
double
private
the i component of a vector in D space
j
double
private
The j component of a vector in D space
k
double
private
The z component of a vector in D 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 For this assignment double variables are considered equal if they are within precision of each other, see note at the end.
Magnitudesqrtijk
If the value is not equal to then scale the vector by its magnitude with the following series of equations:
ifraciMagnitude
jfracjMagnitude
kfrackMagnitude
Note: in the case where the magnitude is equal to all fields should be initialized to
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 For this assignment double variables are considered equal if they are within precision of each other, see note at the end.
Magnitudesqrtijk
If the value is not equal to then scale the vector by its magnitude with the following series of equations:
ifraciMagnitude
jfracjMagnitude
kfrackMagnitude
Note: in the case where the magnitude is equal to all fields should be initialized to
public
UnitVector
none
Construct a newly allocated UnitVector object with all fields instantiated to 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 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:
ithis.jbkthis.kbj
jthis.kbithis.ibk
kthis.ibjthis.jbi
Confirm that the magnitude of the UnitVector is equal to For this assignment double variables are considered equal if they are within precision of each other, see note at the end.
Magnitudesqrtijk
If the value is not equal to 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
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