Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA Implementing a 2-D Vector Class Out: 11/6 Due 11/17 by 11:50 PM Learning Ob

ID: 1770412 • Letter: J

Question

JAVA

Implementing a 2-D Vector Class Out: 11/6 Due 11/17 by 11:50 PM Learning Objectives Implementing a Class Writing Constructors, Mutators and Accessors . Testing a Class Definition 1. A vector is defined as an element of a vector space. In the commonly used vector space R" (Euclidean n-space), a vector is denoted by n coordinates and can be specified as (ri r). Vectors are usu- ally referred to by the number of coordinates they have. A 2-dimensional vector (ri,r2) is may be referred to as a two-vector. More generally, an n-dimensional vector may be referred to as n- vector Binary operations such as addition, subtraction and multiplication by scalars are defined on vectors. Vector multiplication is not unique; different types of vector products, such as the dot product and cross product are defined as binary operations on vectors. The vector norn of a two-vector u-(r,y), denoted 1 Definition 2. is equals to V Definition 3. The unit vector of a two-vector u-(x,y), denoted F = .it). The norn of the unit vector is l. The unit vector for the ero vector is undelined Definition 4. Two vectors in R2. V1 = (ri,y.) and v2 = (x2,p) are equal if and only if corresponding coordinates are equal: that is, ri-12 and Adding Vectors in R2 Duncan Fall 2017

Explanation / Answer

Vector2D.java

Vector2DDemo.java

Sample Output:

Enter x and y components of the first vector->
5 6
Enter x and y components of the second vector->
4 3
Enter x and y components of the third vector->
-2 4

<5.0, 6.0>
<4.0, 3.0>
<-2.0, 4.0>

(v1 + v2) - (v1 -v3) = <2.0, 7.0>
||(v1 + v2) - (v1 -v3)|| = <0.27472112789737807, 0.999230769116934>

unit(v1) x sqrt(v1.v1) = <5.0, 7.7661684474903785>
The x-component of (v2 - v3) / ||v2 - v3|| = 0.9863939238321437
The y-component of (v2 - v3) / ||v2 - v3|| = -0.7119335046677415

v3 = <4.0, -2.0>
v4 = <4.0, -2.0>
Is unit(4 x v4) equal to unit(v4)? false

Are ||v2 - v3|| and ||v2 + v3|| equal? false