Skip to content

Instantly share code, notes, and snippets.

@kellyelton
Created September 9, 2020 08:10
Show Gist options
  • Save kellyelton/aee606081a0add085646565f15aab7db to your computer and use it in GitHub Desktop.
Save kellyelton/aee606081a0add085646565f15aab7db to your computer and use it in GitHub Desktop.
# Copyright Kelly Elton 2020
# All Rights Reserved
set x to 0
set y to 0
function add with othervector vector
return vector
x: .x + othervector.x
y: .y + othervector.y
function distance with tovector vector
set left to .math.pow
value: tovector.x - .x
power: 2
set right to .math.pow
value: tovector.y - .y
power: 2
return .math.sqrt
value: left + right
function normalize
set distance to .math.sqrt
value: .x * .x + .y * .y
return vector
x: .x / distance
y: .y / distance
operator + with othervector vector
return add with othervector: othervector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment