Skip to content

Instantly share code, notes, and snippets.

@RSully
Created March 9, 2012 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RSully/2006091 to your computer and use it in GitHub Desktop.
Save RSully/2006091 to your computer and use it in GitHub Desktop.
Vector summation calculator
# Get the amount of vectors we need to sum
Input "SUM HOW MANY? ", A
# Clear the previous lists
ClrList lVSUA
ClrList lVSUB
ClrList lVSUX
ClrList lVSUY
# Zero-out each list with A items
A->dim(lVSUA)
A->dim(lVSUB)
A->dim(lVSUX)
A->dim(lVSUY)
# Loop through each position
For(I,1,A)
# Input mag and angle
DISP "VECT", I
Input "M?", K
Input "A?", L
# Update mag/ang in lists
K->lVSUA(I)
L->lVSUB(I)
End
# Loop through again:
For(I,1,A)
# Get ref to mag/angle
lVSUA(I)->K
lVSUB(I)->L
# Convert and insert into new list for X/Y
P:Rx(K,L)->P
P:Ry(K,L)->Q
P->lVSUX(I)
Q->lVSUY(I)
End
# Summation X/Y
sum(lVSUX)
sum(lVSUY)
# Output final result of new vector
R:Pr(sum(lVSUX), sum(lVSUY))
R:Pº(sum(lVSUX), sum(lVSUY))
@unixpickle
Copy link

I feel bad for the poor sucker that had to type this up on the computer...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment