Thursday, October 18, 2007

HP-35s Euclid Implementation - XIV : Barycentric to Cartesian coordinates

Going from barycentric to cartesian coordinates (problem 15 in the requirements) is the easy part of Cartesian<->Barycentric 2D/3D conversion, this will be a much shorter blog entry than this one!

Stack Input/Output:
3D case: [[b1, b2, b3], Y, Z, T | L]-> XEQ A ->[[x, y, z], Y, Z, T | [b1, b2, b3]]

2D case: [[b1, b2, b3], Y, Z, T | L]-> XEQ A ->[[x, y], Y, Z, T | [b1, b2, b3]]
Variables:

Reads:
K : First vertex (3D vector), in 3D case. Populated by the T program.
L : Second vertex (3D vector), in 3D case. Populated by the T program.
M : Third vertex (3D vector), in 3D case. Populated by the T program.
U : First vertex of triangle projected to 2D (2D vector), in 2D case. Populated by the T program.
V : Second vertex of triangle projected to 2D (2D vector), in 2D case. Populated by the T program.
W : Third vertex of triangle projected to 2D (2D vector), in 2D case. Populated by the T program.
Program:
A001 LBL A
A002 ABS
A003 RDN
A004 FS? 2
A005 GTO A008
A006 eq Kx([1,0,0]xLASTX)+Lx([0,1,0]xLASTX)+Mx([0,0,1]xLASTX)
A007 RTN
A008 eq Ux([1,0,0]xLASTX)+Vx([0,1,0]xLASTX)+Wx([0,0,1]xLASTX)
A009 RTN
Comments:

Terms of use.

Mnemonics: None realy, but letter is left to B, the program label for Barycentric to Cartesian conversion.

If we are working in 2D (flag 2 set) we are applying the weights (barycentric coordinates) to the 2D coordinate's of the projected triangle (line A008) else applying the weights to the vertexes 3D coordinates (line A006).

No comments: