The program accepts triangle's first point in the Z stack register, second point in Y stack register and third point in the X stack register, all expected to be 3D vectors. Program performs two tasks:

- Store the points in the variables K (first point), L (second point) and M (third point). These variables will be used later in solving triangle problems.
- Returns in the X stack register a vector normal to the plane defined by the triangle computed as (L-K)x(M-K) (x is here the cross product). This gives the area of the triangle since the length of this vector is twice the area (keystrokes: ABS, 2, /).

[[x2, y2, z2], [x1, y1, z1], [x0, y0, z0] | L]->XEQ T->[[nx, ny, nz], [x2, y2, z2], [x1, y1, z1], [x0, y0, z0] | L]Where v0=(x0, y0, z0) is first, v1=(x1, y1, z1) is second, v2=(x2, y2, z2) is the third triangle vertex and [nx, ny, nz] is the cross product (v1-v0)x(v2-v0).

Variables:

Writes:

K : First vertex.Program:

L : Second vertex.

M : Third vertex.

T001 LBL TComments:

TOO2 5

T003 STO I

T004 STO(I)

T005 RDN

T006 4

T007 STO I

T008 RDN

T009 LASTX

T010 STO(I)

T011 RDN

T012 STO M

T013 RDN

T014 STO L

T015 RDN

T016 STO K

T017 R^

T018 X<>Y

T019 -

T020 RDN

T021 RDN

T022 LASTX

T023 -

T024 X<>Y

T025 RDN

T026 XEQ X001

T027 RCL(I)

T028 ABS

T029 RDN

T030 RCL K

T031 RCL L

T032 RCL M

T033 R^

T034 RTN

Terms of use.

Mnemonic: T for triangle.

If end user need to compute the plane's normalized implicit equation she may simply do XEQ P since X stack register contains a vector normal to the plane and Y register a point in the plane (triangle's third vertex).

Change history:

20071018:1950UTC : This program has been modified as a part of providing for Cartesion to Barycentric coordinate transformation.

## No comments:

Post a Comment