Task
Implement a Vector class (or a set of functions) that models a Physical Vector. The four basic operations and a pretty print function should be implemented.



The Vector may be initialized in any reasonable way.

 Start and end points, and direction
 Angular coefficient and value (length)


The four operations to be implemented are:

 Vector  +  Vector addition
 Vector  -  Vector subtraction
 Vector  *  scalar multiplication
 Vector  /  scalar division


' FB 1.05.0 Win64
 
Type Vector
  As Double x, y
  Declare Operator Cast() As String
End Type
 
Operator Vector.Cast() As String
  Return "[" + Str(x) + ", " + Str(y) + "]"
End Operator
 
Operator + (vec1 As Vector, vec2 As Vector) As Vector
  Return Type<Vector>(vec1.x + vec2.x, vec1.y + vec2.y) 
End Operator
 
Operator - (vec1 As Vector, vec2 As Vector) As Vector
  Return Type<Vector>(vec1.x - vec2.x, vec1.y - vec2.y) 
End Operator
 
Operator * (vec As Vector, scalar As Double) As Vector
  Return Type<Vector>(vec.x * scalar, vec.y * scalar) 
End Operator
 
Operator / (vec As Vector, scalar As Double) As Vector
  ' No need to check for division by zero as we're using Doubles
  Return Type<Vector>(vec.x / scalar, vec.y / scalar) 
End Operator
 
Dim v1 As Vector = (5, 7)
Dim v2 As Vector = (2, 3)
Print v1; " +  "; v2; " = "; v1 + v2
Print v1; " -  "; v2; " = "; v1 - v2
Print v1; " * "; 11; "     = "; v1 * 11.0
Print v1; " / ";  2; "      = "; v1 / 2.0
Print
Print "Press any key to quit"
Sleep