Contents Links Search
 

RPN Scripts

RPN Documentation

Submit Script

Conversion
   Conversions
   Convert
   Euro
   Euro_Calculator
   Soundex
Engineering
   Feet_&_Inch
   Units
   Water
Entertainment
   Master_Mind
   Sticks!
Finance
   Annuity
   Euro_Calculator
   TVM_Financial_Functions
Math
   3D_Vectors_v1.2
   Base
   Base_Conversions
   Complex_Arithmetic
   Complex_Math
   Discrete_Math
   EBBases
   Fractions
   Fractions
   Least
   Logs_&_Powers
   Misc
   Regressions
   Scientific
   Scientific_Functions
   Scientific_Programmable
   Simple_Complex_Math
   Standard_Normal_Distribution
   Trig
Misc
   Health
   Husband's_Calculator
Physics
   Angle_of_View
   Depth_of_Field
   Physics_Functions
Time
   Clock
   Julian
   Multiple_Timer
   Stop5Watch
   Stopwatch
   Timer
Utility
   Board_Foot_Calculator
   Calendar_Functions
   Checkbook_II
   MiniG
   Stack_Handling_and_Saving
   WindChill

3D Vectors v1.2
Mike Williams - email


summary
Basic 3D vector functionality.

instructions
This script supports 2 vectors, A and B. A vector
is defined using the top 3 stack values in reverse
order (z is top of the stack, y is next, then x) -
use >A to define A and >B to define B. A> and B>
put the current vector values on the stack. A<>B
swaps the values of A and B.

All vector operators leave their results on the
stack to be then stored or cleared.

Binary operators that are are A+B (addition), A-B
(subtraction), A.B (dot product) and AxB (cross
product).

Unary operators are |A| (length), a^ (unit vector,
or direction cosines), and s.A (scaling).

Clear removes 3 values from the stack as a quick
way of removing a vector's values.

code
RPN.2.f+3
\V1.0 - nuff said
\V1.1 - test for 0 length in unit vec
\V1.2 - fix cross product
\Get & put A & B vectors
[a]xaxbxc;
[b]xdxexf;
[x]XcXbXa;
[y]XfXeXd;
\Duplicate a vector
[d]g3g3g3;
\Vector functions
[l]r32Pr32Pr32P++s; \length
[s]g1r5*r2g1r5*r2r4*; \scale
[t]r6r4+r5r4+r4r4+; \sum
[u]r6r4-r5r4-r4r4-; \difference
[v]r6r4*r5r4*r4r4*++; \dot product
"3D Vector"
"A+B: vector sum" CaCbCt;
"A-B: vector difference" CaCbCu;
"A.B: vector dot product" CaCbCv;
"AxB: vector product" xbxf*xcxe*-xcxd*xaxf*-xaxe*xbxd*-;
~
"|A|: vector length" CaCl;
"a^: unit vector" CaClg10=0(d1D'Zero length vector!|OK|'d1:Car4tCs);
"s.A: scale vector" ?1Car4Cs;
"A<>B: swap vectors" CaCbCxCy;
~
">A: get A from stack" ?3Cx;
">B: get B from stack" ?3Cy;
"A>: put A on stack" Ca;
"B>: put B on stack" Cb;
~
"Clear: pop vector values" ?3d1d1d1;

top
Nth Lab
©1996 - 2001 all rights reserved
August 03, 2001
contact