SimpleVector - Interactive examples

back

Division methods

Note when trying to divide by zero the methods will actually throw a DivisionByZeroError exception. In this page we just set the result to a zero vector instead.

Vector division

v1.divide(v2)

v1
x:3, y:0
v2
x:0, y:3
v1.divide(v2)
x:0, y:0

v1.divideX(v2

v1
x:3, y:0
v2
x:0, y:3
v1.divideX(v2)
x:0, y:0

v1.divideY(v2)

v1
x:3, y:0
v2
x:0, y:3
v1.divideY(v2)
x:3, y:0

Scalar division

Scalar to divide:

v1.divideScalar(v2)

v1
x:3, y:0
v1.divideScalar(2)
x:1.5, y:0

v1.divideScalarX(v2

v1
x:3, y:0
v1.divideScalarX(2)
x:1.5, y:0

v1.divideScalarY(v2)

v1
x:3, y:0
v1.divideScalarY(2)
x:3, y:0