Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Vector3D.java Your task is to complete the implementation of a streamlined Vector3D class that describes a vector in R 3 . This class consists of

Vector3D.java

Your task is to complete the implementation of a streamlined Vector3D class that describes a vector in R3 . This class consists of three instance variables, all of type double, called x, y, and z. (DO NOT change the signature of any method or implement any additional ones). Provide the missing code segment where indicated in the class below:

public class Vector3D {

// The x, y and z coordinates of this 3-D vector.

private double x,y,z;

// constructs a three-vector whose x, y, and z coordinates are 0.0, 0.0, and 0.0, respectively.

public Vector3D() {

// TO DO (A)

}

/** constructs a three-vector

* @param xVal the value of the first coordinate

* @param yVal the value of the second coordinate

* @param zVal the value of the third coordinate

*/

public Vector3D(double xVal, double yVal, double zVal) {

// TO DO (B)

}

/**

* @return the length of the vector

*/

public double length() {

// TO DO (C)

}

/**

* Computes the cross product of this vector and the specified 3-D vector.

* @param v a 3-D vector

* @return a 3-D Vector representing the cross product of two 3-D vectors.

*/

public Vector3D cross(Vector3D v) {

// TO DO (D)

}

/**

* Computes the scalar product of this vector and the specified number.

* @param n a scalar.

* @return a 3-D vector represent the scalar product

*/

public Vector3D times(double n) {

// TO DO (E)

}

/**

* Computes the unit vector of this vector.

* Given a 3-D vector v = , its unit vector is

* @return a 3-D unit vector

*/

public Vector3D unit() {

// TO DO (G)

}

/**

* Gives a string representation of a 3-d vector in this format: .

* @return a string representing this 3-D vector.

*/

public String toString() {

// TO DO (H)

}

/**

* Compares two 3-Vectors.

* @param o an Object reference

* @return false when this object does not have the same coordinates as the specified Vector3D object that o holds; otherwise, true

*/

public boolean equals(Object o) {

// TO DO (I)

}

}

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

=+a. What is the price level? What is the velocity of money?

Answered: 1 week ago

Question

LO12.3 Explain how demand is seen by a pure monopoly.

Answered: 1 week ago