18 lines
582 B
Plaintext
18 lines
582 B
Plaintext
v1 = PVector(5, 7)
|
|
v2 = PVector(2, 3)
|
|
|
|
println('{} {} {} {}\n'.format( v1.x, v1.y, v1.mag(), v1.heading()))
|
|
|
|
# math overloaded operators (static methods in the comments)
|
|
println(v1 + v2) # PVector.add(v1, v2)
|
|
println(v1 - v2) # PVector.sub(v1, v2)
|
|
println(v1 * 11) # PVector.mult(v1, 11)
|
|
println(v1 / 2) # PVector.div(v1, 2)
|
|
println('')
|
|
|
|
# object methods (related augmented assigment in the comments)
|
|
println(v1.sub(v1)) # v1 -= v1; println(v1)
|
|
println(v1.add(v2)) # v1 += v2; println(v2)
|
|
println(v1.mult(10)) # v1 *= 10; println(v1)
|
|
println(v1.div(10)) # v1 /= 10; println(v1)
|