REVO2700 Follow the bouncing ball X function perpDist tP,tLine put item 1 of tLine into x2 put item 2 of tLine into y2 put item 3 of tLine into x3 put item 4 of tLine into y3 put item 1 of tP into x1 put item 2 of tP into y1 if x3-x2 is 0 then return abs(x1-x2) else put (y3-y2)/(x3-x2) into m -- The slope return abs(m*(x1-x2)-(y1-Y2))/sqrt(1+m*m) end if end perpDist on openstack choose the browse tool end openstack on preOpenStack choose the browse tool end preOpenStack + U Lucida Grande U W U 9 U Times New Roman W Times New Roman $ W Times New Roman W 9 W 9 U 9 W 9 W Lucida Grande cREVGeometryCache stackID 6556 cREVGeneral scriptChecksum 9kmP8 bookmarks debugObjects ?button id 1005 of card id 1002 of stack "Rubber Ball" graphic id 1003 of card id 1002 of stack "Elastic ball" graphic id 5743 of card id 5738 of stack "Rubber ball" graphic id 1003 of card id 1002 of stack "Rubber ball" button id 5748 of card id 5738 of stack "Rubber ball" graphic id 5732 of card id 5738 of stack "Rubber ball" graphic id 5732 of card id 5738 of stack "myLine" graphic id 5815 of card id 5827 of stack "Rubber ball" graphic id 5815 of card id 5827 of stack "Graphic 1" graphic id 5815 of card id 5827 of stack "Bouncing ball" graphic id 5850 of card id 5863 of stack "Bouncing ball" graphic id 5815 of card id 5827 of stack "Graphic tools" graphic id 5884 of card id 5897 of stack "Graphic tools" graphic id 5917 of card id 5929 of stack "Graphic tools" graphic id 5917 of card id 5929 of stack "card id 5929" graphic id 5732 of card id 5738 of stack "card id 5929" graphic id 6045 of card id 6047 of stack "Follow the bouncing ball" graphic id 5884 of card id 5897 of stack "Follow the bouncing ball" graphic id 6200 of card id 6202 of stack "Follow the bouncing ball"handlerList perpDist openstack preOpenStackscriptSelection char 477 to 476prevHandler perpDisttempScript script )
function perpDist tP,tLine
put item 1 of tLine into x2
put item 2 of tLine into y2
put item 3 of tLine into x3
put item 4 of tLine into y3
put item 1 of tP into x1
put item 2 of tP into y1
if x3-x2 is 0 then
return abs(x1-x2)
else
put (y3-y2)/(x3-x2) into m -- The slope
return abs(m*(x1-x2)-(y1-Y2))/sqrt(1+m*m)
end if
end perpDist
on openstack
choose the browse tool
end openstack
on preOpenStack
choose the browse tool
end preOpenStack
P cREVGeometryCacheIDs 1108343705619 57301108342523075 57281108424165944 57471108424150711 57461109349981985 61771108342633221 57291108340866467 57271108343966445 57311107870321097 1003 cREVGeometrycache order total 9 cREVGeneral scriptChecksum h)ژ@ح\@ bookmarks handlerList breakPoints tempScript prevHandler perpDistscriptSelection char 1 to 0script _ ` a b c r s ! j Pmfunction thePolyLines tPolyPoints repeat with i = 1 to the number of lines in tPolyPoints put line i of tPolyPoints & comma & line i+1 of tPolyPoints & return after results end repeat delete last line of results return results end thePolyLines function perpDist tP,tLine put item 1 of tLine into x2 put item 2 of tLine into y2 put item 3 of tLine into x3 put item 4 of tLine into y3 put item 1 of tP into x1 put item 2 of tP into y1 if x3-x2 is 0 then return (x1-x2) else put (y3-y2)/(x3-x2) into m -- The slope return (m*(x1-x2)-(y1-Y2))/sqrt(1+m*m) end if end perpDist cREVGeometryCacheIDs 1108343705619 57361108395006710 57441108511492272 58031109350108503 61781108342633221 57351108506874770 57681108343966445 57371108498536155 57551108342523075 57341108498536156 57561108498307386 57541108430058696 57481107870321097 57321108340866467 5733 cREVGeometryCache order total 14 cREVGeneral scriptChecksum *ˎ$)R饍 bookmarks breakPoints handlerList thePolyLines perpDistscriptSelection char 1 to 256prevHandler thePolyLinestempScript scriptfunction thePolyLines tPolyPoints
repeat with i = 1 to the number of lines in tPolyPoints
put line i of tPolyPoints & comma & line i+1 of tPolyPoints & return after results
end repeat
delete last line of results
return results
end thePolyLines
function perpDist tP,tLine
put item 1 of tLine into x2
put item 2 of tLine into y2
put item 3 of tLine into x3
put item 4 of tLine into y3
put item 1 of tP into x1
put item 2 of tP into y1
if x3-x2 is 0 then
return (x1-x2)
else
put (y3-y2)/(x3-x2) into m -- The slope
return (m*(x1-x2)-(y1-Y2))/sqrt(1+m*m)
end if
end perpDist
e f g h i p t { | d z " Pmfunction thePolyLines tPolyPoints repeat with i = 1 to the number of lines in tPolyPoints put line i of tPolyPoints & comma & line i+1 of tPolyPoints & return after results end repeat delete last line of results return results end thePolyLines function perpDist tP,tLine put item 1 of tLine into x2 put item 2 of tLine into y2 put item 3 of tLine into x3 put item 4 of tLine into y3 put item 1 of tP into x1 put item 2 of tP into y1 if x3-x2 is 0 then return (x1-x2) else put (y3-y2)/(x3-x2) into m -- The slope return (m*(x1-x2)-(y1-Y2))/sqrt(1+m*m) end if end perpDist cREVGeometryCacheIDs 1108343705619 60361108395006710 60381108511492272 60431108343966445 60371108506874770 60421108498536155 60401109350115241 61791108498536156 60411108899014881 60441108498307386 60461108942517596 60971108430058696 60391107870321097 60451108942420955 60951108342633221 60351108342523075 60341108942503466 60961108340866467 6033 cREVGeometryCache total 18order cREVGeneral scriptChecksum *ˎ$)R饍 bookmarks handlerList thePolyLines perpDistbreakPoints tempScript prevHandler thePolyLinesscriptSelection char 1 to 256scriptfunction thePolyLines tPolyPoints
repeat with i = 1 to the number of lines in tPolyPoints
put line i of tPolyPoints & comma & line i+1 of tPolyPoints & return after results
end repeat
delete last line of results
return results
end thePolyLines
function perpDist tP,tLine
put item 1 of tLine into x2
put item 2 of tLine into y2
put item 3 of tLine into x3
put item 4 of tLine into y3
put item 1 of tP into x1
put item 2 of tP into y1
if x3-x2 is 0 then
return (x1-x2)
else
put (y3-y2)/(x3-x2) into m -- The slope
return (m*(x1-x2)-(y1-Y2))/sqrt(1+m*m)
end if
end perpDist
# P Ffunction ProjPointLiesWithinEndPts tProjPt,tLine put item 1 to 2 of tLine into tLinePt1 put item 3 to 4 of tLine into tLinePt2 put theTwoPtDist(tLinePt1,tLinePt2) into L put theTwoPtDist(tProjPt,tLinePt1) into s1 put theTwoPtDist(tProjPt,tLinePt2) into s2 if s1 < L and s2 < L then return true else return false end ProjPointLiesWithinEndPts end tDistProjPtFromEitherEnd function theDistPtAndEndPoints p1,tLine put item 1 to 2 of tLine into p2 put item 3 to 4 of tLine into p3 put theTwoPtDist(p1,p2) into s1 put theTwoPtDist(p1,p3) into s2 return s1+s2 end theDistPtAndEndPoints function theTwoPtDist p1,p2 put item 1 of p1 into x1 put item 2 of p1 into y1 put item 1 of p2 into x2 put item 2 of p2 into y2 return sqrt((x2-x1)^2 + (y2-y1)^2) end theTwoPtDist on changeToReflectedVel tLine put item 1 to 2 of tLine into p1 put item 3 to 4 of tLine into p2 put the loc of me into tLoc put theTwoPtDist(tLoc,p1) into d1 put theTwoPtDist(tLoc,p2) into d2 if d1