Tuesday, April 19, 2011

Geometry: Distance and Midpoint

 This basically finds the midpoint and distance on a number line, a plane, and 3D space.
e.g. (0,0,0) and (1,0,0) :They are exactly one distance unit and have a midpoint of (0.5,0,0)

-- Distance and Midpoint --
:Disp "Dist, MidPoint","(1-3)"
:Input "Num Dimensions: ",X
:If X=1
:Then
:Prompt A,B
:abs(A-B)C
:If A<B
:(C/2)+AD
:If B<A
:(C/2)+BD
:Disp "MP:",D,"DIST:",C
:Else
:If X=2
:Then
:Prompt X,Y
:Input "X2:",A
:Input "Y2:",B
:((X-A)2+(Y-B)2)D
:((A+X)/2)Q
:((B+Y)/2)R
:Xdim(L1)
:QL1(1)
:RL1(2)
:Disp "MIDPOINT: XY",L1,"DIST:",D
:Else
:If X=3
:Then
:Prompt X,Y,Z
:Input "X2=?",A
:Input "Y2=?",B
:Input "Z2=?",C
:((A-X)2+(B-Y)2+(C-Z)2)D
:((A+X)/2)Q
:((B+Y)/2)R
:((C+Z)/2)S
:Xdim(L1)
:QL1(1)
:RL1(2)
:SL1(3)
:Disp "MIDPOINT: XYZ",L1,"Dist:",D
:End

No comments:

Post a Comment