I choose to modify the S program so that it computes the signed distance in 2D (as before) if flag 2 is set and else computes signed distance in 3D (to the plane defined by the P program); problem 10 of the requirements.
Stack Input/Output:
2D case:
[[x, y], Y, Z, T | L]-> XEQ S ->[d, Y, Z, T | [x, y]]3D case:
[[x, y, z], Y, Z, T | L]-> XEQ S ->[d, Y, Z, T | [x, y, z]]Where (x, y) or (x, y, z) is point to find distance to and d is the signed distance.
Variables:
Reads:
C : [a, b, c], constants of line's normalized implicit equation. Populated by the L program. Reads in 2D case (flag 2 set).Program:
N : Plane's normalized normal vector. Populated by the P program. Reads in 3D case.
O : Plane's distance to origo (0, 0, 0). Populated by the P program. Reads in 3D case.
S001 LBL SComments:
S002 ABS
S003 RDN
S004 FS? 2
S005 GTO 008
S006 eq LASTXxN+O
S007 RTN
S008 eq (([1,0,0]xC)x([1, 0]xLASTX))+(([0,1,0]xC)x([0,1]xLASTX))+[0,0,1]xC
S009 RTN
Terms of use.
As before point to find signed distance to in the X stack register: Again, if had an dim operator for vectors would not need for the end user to toggle the 2 flag, could branch on dimension of argument in the X stack register.
No comments:
Post a Comment