Sunday, August 18, 2024

Casio fx-CG50: Intersection of Two Planes

Casio fx-CG50: Intersection of Two Planes



Introduction


The program INTPLACE calculates a possible line:


r = V + t * D


where V = constant vector, D = directional vector, r = linear vector


The planes are have the equations:


A * X + B * Y + C * Z = D

E * X + F * Y + G * Z = H


The directional vector is calculated by the cross product of vectors:


[ A, B, C ] × [ E, F, G ]

= < B * F – E * C, -(A * F – C * D), A * E – B * D >


A system of equations is solved for two of the variables, with the third variable, often z, designated an arbitrary value, often 0.



Casio fx-CG 50 Program: INTPLACE

Bytes: 312


Due to the mixed use of vectors and matrices on the calculator, I have the program take inputs and store them in variables A through H, so we have the greatest flexibility.


The planes have the equations:


A * X + B * Y + C * Z = D

E * X + F * Y + G * Z = H


There is a for loop to simulate a small wait cycle. There is no Wait command in Casio basic.


Code:


For 1 → I To 25

Locate 1, 2, “INTERSECT 2 PLANES”

Blue Locate 1, 4, “AX+BY+CZ=D”

Red Locate 1, 5, “EX+FY+GZ=H”

Next


ClrText

A”? → A

B”? → B

C”? → C

D”? → D

E”? → E

F”? → F

G”? → G

H”? → H

CrossP([[A,B,C],[[E,F,G]]) → Vct D

[[A,B][E,F]]^-1 × [[D][H]] → VctH

Mat V [1,1] → I

Mat V [2, 1] → J

[[I, J, 0]] → Mat V


ClrText

Vct V + T × Vct D”

0 ≤ T ≤ 1” ◢

Vct V” ◢

Vct V ◢

Vct D” ◢

Vct D



The program assumes that z-component of the calculated directional vector (Vct D) is nonzero. The z-component of the constant vector (Vct V) is assigned to be 0.


Example


3 * X – 5 * Y + Z = 4

X – 2 * Y + Z = 0


A = 3

B = -5

C = 1

D = 4

E = 1

F = -2

G = 1

H = 0


Constant Vector:

Vct V = < 8, 4, 0 >


Directional Vector:

Vct D = < -3, -2, -1 >


A line that intersects plane is:


r(t) = < 8, 4, 0 > + t * < -3, -2, -1 >

for 0 ≤ t ≤ 1


Source


Tremblay, Christopher. Mathematics for Game Developers. Thomson Course Technology. Boston, MA. 2004. ISBN 1-59200-038-X. pp. 103 – 105.




Eddie


All original content copyright, © 2011-2024. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.