Implement a data type Vector3D for three-dimensional vectors that has the same API as Vector, except that
Question:
Implement a data type Vector3D for three-dimensional vectors that has the same API as Vector, except that the constructor takes three doub7e values as arguments. Also, add a cross-product method: the cross-product of two vectors is another vector, defined by the equation \[\mathbf{a} \times \mathbf{b}=\mathbf{c}|\mathbf{a}||\mathbf{b}| \sin \theta\] where \(\mathbf{c}\) is the unit normal vector perpendicular to both \(\mathbf{a}\) and \(\mathbf{b}\), and \(\theta\) is the angle between \(\mathbf{a}\) and \(\mathbf{b}\). In Cartesian coordinates, the following equation defines the cross-product: \[\left(a_{0}, a_{1}, a_{2}ight) \times\left(b_{0}, b_{1}, b_{2}ight)=\left(a_{1} b_{2}-a_{2} b_{1}, a_{2} b_{0}-a_{0} b_{2}, a_{0} b_{1}-a_{1} b_{0}ight)\]
The cross-product arises in the definition of torque, angular momentum, and vector operator curl. Also, \(|\mathbf{a} \times \mathbf{b}|\) is the area of the parallelogram with sides \(\mathbf{a}\) and \(\mathbf{b}\).
Step by Step Answer:
Introduction To Programming In Java An Interdisciplinary Approach
ISBN: 9780672337840
2nd Edition
Authors: Robert Sedgewick, Kevin Wayne