Deriving an angle from three points
40,116 98,186 132,118 How would one determine the angle created from three points, such as those above? Thanks, Mark___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
Mark- Tuesday, December 15, 2009, 10:21:47 PM, you wrote: > 40,116 > 98,186 > 132,118 > How would one determine the angle created from three points, such as those > above? There are three angles. Which one are you interested in? -- -Mark Wieder mwie...@ahsoftware.net ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
I never took trig, but I imagine some of Rev's trig functions might be helpful in determining this. If it's any help, here's a button handler that draws the angle: on mouseUp put "40,116/98,186/132,118" into tPointsList replace "/" with cr in tPointsList set the style of the templateGraphic to "polygon" set the lineSize of the templateGraphic to 1 set the showBorder of the templateGraphic to true -- to show the grc edge create grc "angle" set the points of grc "angle" to tPointsList end mouseUp When I draw it, I see there is a right angle at the bottomRight of it that might serve as a reference point of some sort? Of course a real numbers person wouldn't need to draw anything to "see" this. It would be ,. I'll be interested to see the solution too. Phil Davis On 12/15/09 10:21 PM, Mark Swindell wrote: 40,116 98,186 132,118 How would one determine the angle created from three points, such as those above? Thanks, Mark___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution -- Phil Davis PDS Labs Professional Software Development http://pdslabs.net ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
> > On 12/15/09 10:21 PM, Mark Swindell wrote: >> 40,116 >> 98,186 >> 132,118 >> >> How would one determine the angle created from three points, such as those >> above? Hi Mark, I'm using the following handlers. SurfaceTriangle is used to determine if you compute the outer (>180) or inner angle with summit c in calcangle. HTH Jacques function SurfaceTriangle a,c,b -- -- a,c,b: points -- returns twice the surface of triangle a,c,b -- the result is signed, positive if points follow each other clockwise, -- negative otherwise. -- aligned points return zero. -- put ((item 1 of c - item 1 of a)*(item 2 of b - item 2 of a)\ - (item 1 of b - item 1 of a)*(item 2 of c - item 2 of a)) into aire return aire end SurfaceTriangle function calcAngle a,c,b -- -- a,c,b : points. -- returns angle between ca and cb in degrees -- put Distance(c,b) into da put Distance(a,c) into db put Distance(a,b) into dc put (da + db + dc)/2 into p put sqrt(p*(p-dc)/(db*da)) into lecos if lecos > 1 then put 1 into lecos if lecos < -1 then put -1 into lecos put acos(lecos) * 180 / pi into alpha put 2 * alpha into alpha if SurfaceTriangle(a,c,b) then return alpha else return 360-alpha end if end calcAngle ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
As usual, I forgot something... Distance is merely this brave old Pythagora: function Distance a,b -- -- a,b : points -- returns distance (real) between a and b -- return sqrt((item 1 of a - item 1 of b)^2 + (item 2 of a - item 2 of b)^2) end distance Jacques Le 16 déc. 2009 à 09:47, Jacques Hausser a écrit : >> >> On 12/15/09 10:21 PM, Mark Swindell wrote: >>> 40,116 >>> 98,186 >>> 132,118 >>> >>> How would one determine the angle created from three points, such as those >>> above? > > Hi Mark, > > I'm using the following handlers. SurfaceTriangle is used to determine if you > compute the outer (>180) or inner angle with summit c in calcangle. > > HTH > > Jacques > > function SurfaceTriangle a,c,b > -- > -- a,c,b: points > -- returns twice the surface of triangle a,c,b > -- the result is signed, positive if points follow each other clockwise, > -- negative otherwise. > -- aligned points return zero. > -- > put ((item 1 of c - item 1 of a)*(item 2 of b - item 2 of a)\ > - (item 1 of b - item 1 of a)*(item 2 of c - item 2 of a)) into aire > return aire > end SurfaceTriangle > > function calcAngle a,c,b > -- > -- a,c,b : points. > -- returns angle between ca and cb in degrees > -- > put Distance(c,b) into da > put Distance(a,c) into db > put Distance(a,b) into dc > put (da + db + dc)/2 into p > put sqrt(p*(p-dc)/(db*da)) into lecos > if lecos > 1 then put 1 into lecos > if lecos < -1 then put -1 into lecos > put acos(lecos) * 180 / pi into alpha > put 2 * alpha into alpha > if SurfaceTriangle(a,c,b) then > return alpha > else > return 360-alpha > end if > end calcAngle > > ___ > use-revolution mailing list > use-revolution@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-revolution ** Prof. Jacques Hausser Department of Ecology and Evolution Biophore / Sorge University of Lausanne CH 1015 Lausanne please use my private address: 6 route de Burtigny CH-1269 Bassins tel/fax:++ 41 22 366 19 40 mobile: ++ 41 79 757 05 24 E-Mail: jacques.haus...@unil.ch *** ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
Mark- Tuesday, December 15, 2009, 10:21:47 PM, you wrote: > 40,116 > 98,186 > 132,118 > How would one determine the angle created from three points, such as those > above? If I can assume that (98,186) is the center of the angle, then you can calculate the angle (actually all three angles) from the lengths of the three sides of the triangle: on mouseUp local pointA, pointB, pointC local lengthA, lengthB, lengthC local tSub local tRadians put "40,116" into pointA put "98,186" into pointB -- assumed center of angle put "132,118" into pointC -- get the lengths of the three sides of the triangle put SideLength(pointA, pointB) into lengthA put SideLength(pointB, pointC) into lengthB put SideLength(pointA, pointC) into lengthC --calculate the angle as arccos( (b2+c2-a2) / 2bc) --the other two angles are arccos( (a2+c2-b2) / 2ac) -- and arccos( (a2+b2-c2) / 2ab) put (lengthB * lengthB) + (lengthC * lengthC) - (lengthA * lengthA) into tSub put acos(tSub / (2 * lengthB * lengthC)) into tRadians put tRadians * 180 / pi -- convert from radians to degrees end mouseUp -- calculate (x2-x1)^2 + (y2-y1)^2 -- return the square root of that function SideLength pPointA, pPointB local lengthX, lengthY set the itemdelimiter to comma put item 1 of pPointB - item 1 of pPointA into lengthX put lengthX * lengthX into lengthX -- x squared put item 2 of pPointB - item 2 of pPointA into lengthY put lengthY * lengthY into lengthY -- y squared return sqrt(lengthX + lengthY) -- length of hypotenuse end SideLength ...and I come up with 64.680313 degrees. -- -Mark Wieder mwie...@ahsoftware.net ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
What about getting the angle from point B to A, then the angle from point B to C, then getting the difference: on mouseUp put cd fld "A" into pointA put cd fld "B" into pointB -- assumed center of angle put cd fld "C" into pointC -- put fGetAngle(pointB, pointA) into angleA put fGetAngle(pointB, pointC) into angleC if angleC > angleA then put angleC - angleA into cd fld "AngleABC" else put angleA - angleC into cd fld "AngleABC" end if end mouseUp function fGetAngle pPoint1, pPoint2 --angle anticlockwise from X axis return atan2(item 2 of pPoint2 - item 2 of pPoint1,item 1 of pPoint2 - item 1 of pPoint1) * 180 / pi end fGetAngle See atan2 in the dictionary. By the way, this gives 66.209226 for the angle. As a test for known angles, try 250,250 200,200 100,373 This is for angles of 45 degrees and 120 degrees. you should get 75 degrees as your answer. -- View this message in context: http://n4.nabble.com/Deriving-an-angle-from-three-points-tp964930p965051.html Sent from the Revolution - User mailing list archive at Nabble.com. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
By the way again, Mark's method is also correct if you fix the variable names as shown below. Normally a triangle with points ABC have their sides named with side b between A and C so it is opposite angle B...etc. on mouseUp put cd fld "A" into pointA put cd fld "B" into pointB -- assumed center of angle put cd fld "C" into pointC -- -- get the lengths of the three sides of the triangle put SideLength(pointA, pointB) into lengthC put SideLength(pointB, pointC) into lengthA put SideLength(pointA, pointC) into lengthB --calculate the angle as arccos( (b2+c2-a2) / 2bc) --the other two angles are arccos( (a2+c2-b2) / 2ac) -- and arccos( (a2+b2-c2) / 2ab) put (lengthA * lengthA) + (lengthC * lengthC) - (lengthB * lengthB) into tSub put acos(tSub / (2 * lengthA * lengthC)) into tRadians put (tRadians * 180 / pi) into cd fld "AngleABC"-- convert from radians to degrees end mouseUp -- calculate (x2-x1)^2 + (y2-y1)^2 -- return the square root of that function SideLength pPointA, pPointB local lengthX, lengthY set the itemdelimiter to comma put item 1 of pPointB - item 1 of pPointA into lengthX put lengthX * lengthX into lengthX -- x squared put item 2 of pPointB - item 2 of pPointA into lengthY put lengthY * lengthY into lengthY -- y squared return sqrt(lengthX + lengthY) -- length of hypotenuse end SideLength -- View this message in context: http://n4.nabble.com/Deriving-an-angle-from-three-points-tp964930p965059.html Sent from the Revolution - User mailing list archive at Nabble.com. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
I really should re-read my mails before sending them :-( I cannot copy and paste scripts directly into mails (I don't know why) so I rewrite them... with bugs ! in function calcangle the line if SurfaceTriangle (a,c,b) then should be if SurfaceTriangle(a,c,b) > 0 then ... but you corrected it already ! Jacques-in-the-moon ** Prof. Jacques Hausser Department of Ecology and Evolution Biophore / Sorge University of Lausanne CH 1015 Lausanne please use my private address: 6 route de Burtigny CH-1269 Bassins tel/fax:++ 41 22 366 19 40 mobile: ++ 41 79 757 05 24 E-Mail: jacques.haus...@unil.ch *** ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
Hi Friends, Did'nt follow all the present thread so don't know if this can help but in case, here is the general way i would use to process such tasks : on mouseUp set the style of the templateGraphic to "polygon" set the opaque of the templateGraphic to "true" set the filled of the templateGraphic to "true" set the backgroundcolor of templateGraphic to "blue" # or what ever color you choose instead set the textcolor of templateGraphic to "blue" # or what ever color you choose instead if there is a grc "new_grc" then delete grc "new_grc" create grc "new_grc" ask "How many sectors do you want to display" if it is not "" then put it into secteurs_nb else exit to top # random example values you will have to replace with the real values you want to display put "" into les_valeurs33 repeat with c = 1 to secteurs_nb put -1+random(2) & return & return after les_valeurs33 end repeat put char 1 to -3 of les_valeurs33 into les_valeurs33 put -40+the height of this cd into graph_diametre put graph_diametre div 2 into graph_rayon put the width of this cd div 2 into x1 put the height of this cd div 2 into y1 put 2*pi / secteurs_nb into langle put langle / 2 into langlecalcule repeat with c = 1 to secteurs_nb put cos((x1*2*pi) + langlecalcule) & "," after the_cos_1 put sin((y1*2*pi) + langlecalcule) & "," after the_sin_1 add langle to langlecalcule end repeat put the_cos_1 after the_cos_1 put the_sin_1 after the_sin_1 put pi / secteurs_nb into langle put "0" into langlecalcule repeat with c = 1 to 2*secteurs_nb put cos((x1*2*pi) + langlecalcule) & "," after the_cos_2 put sin((y1*2*pi) + langlecalcule) & "," after the_sin_2 add langle to langlecalcule end repeat put the_cos_2 after the_cos_2 put the_sin_2 after the_sin_2 # draw the graphic set the points of grc "new_grc" to points_cosin (secteurs_nb ,les_valeurs33 ,x1,y1,the_cos_1,the_sin_1,the_cos_2,the_sin_2,graph_rayon) end mouseUp function points_cosin secteurs_nb ,les_valeurs,x1,y1,the_cos_1,the_sin_1,the_cos_2,the_sin_2,graph_rayon put "" into points_nb put "0" into d repeat with c = 1 to 2*secteurs_nb put (1 / 11) + ((line c of les_valeurs*10) / 11) into active_rayon if c mod 2 = 1 then add 1 to d put x1 & "," & y1 & return & round(x1-(item c of the_cos_2*active_rayon*graph_rayon)),round(y1-(item c of the_sin_2*active_rayon*graph_rayon)) & return & \ round(x1-(item d of the_cos_1*active_rayon*graph_rayon)),round(y1-(item d of the_sin_1*active_rayon*graph_rayon)) & return & \ round(x1-(item 2+c of the_cos_2*active_rayon*graph_rayon)),round(y1-(item 2+c of the_sin_2*active_rayon*graph_rayon)) & return after points_nb else put x1 & "," & y1 & return & round(x1-(item c of the_cos_2*active_rayon*graph_rayon)),round(y1-(item c of the_sin_2*active_rayon*graph_rayon)) & return & \ round(x1-(item 2+c of the_cos_2*active_rayon*graph_rayon)),round(y1-(item 2+c of the_sin_2*active_rayon*graph_rayon)) & return after points_nb add 1 to c end repeat return points_nb & line 1 of points_nb end points_cosin just put this script inside a new stack's button and run it to display the "new_graph" test graph. Just tested and seems to work fine there. Have fun ! Pierre Le 16 déc. 09 à 11:56, Jacques Hausser a écrit : I really should re-read my mails before sending them :-( I cannot copy and paste scripts directly into mails (I don't know why) so I rewrite them... with bugs ! in function calcangle the line if SurfaceTriangle (a,c,b) then should be if SurfaceTriangle(a,c,b) > 0 then ... but you corrected it already ! Jacques-in-the-moon ** Prof. Jacques Hausser Department of Ecology and Evolution Biophore / Sorge University of Lausanne CH 1015 Lausanne please use my private address: 6 route de Burtigny CH-1269 Bassins tel/fax:++ 41 22 366 19 40 mobile: ++ 41 79 757 05 24 E-Mail: jacques.haus...@unil.ch *** ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution -- Pierre Sahores mobile : (33) 6 03 95 77 70 www.wrds.com www.sahores-conseil.com ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
On Dec 15, 2009, at 10:35 PM, Mark Wieder wrote: > Mark- > > Tuesday, December 15, 2009, 10:21:47 PM, you wrote: > >> 40,116 >> 98,186 >> 132,118 > >> How would one determine the angle created from three points, such as those >> above? > > There are three angles. Which one are you interested in? > > — The above represents roughly a V shape with the center point the vertex. I was trying to detemine the internal angle. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
Message: 24 Date: Tue, 15 Dec 2009 22:21:47 -0800 From: Mark Swindell Subject: Deriving an angle from three points To: How to use Revolution Message-ID: Content-Type: text/plain; charset=us-ascii 40,116 98,186 132,118 How would one determine the angle created from three points, such as those above? Thanks, Mark Mark, Here is how easy this is in Turtle Graphics: on mouseUp startTurtle --Initiates the turtle graphics library penup setxy 40,116 pendown put direction(98,186) into tStartAngle setxy 98,186 put direction(132,118) into tEndAngle setxy 132,118 --Not necessary, but visually satisfying put tEndAngle - tStartAngle into dA put dA & cr & 360 - da into msg box choose the browse tool end mouseUP (Assuming your middle point is the apex of the angle you want.) To run this you will need the TG library. Run this in the msg box go url "http://www.jamesphurley.com/jhurleyFolder/TurtleGraphics.rev"; Jim Hurley ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
On Dec 16, 2009, at 1:21 AM, Mark Swindell wrote: > 40,116 > 98,186 > 132,118 > > How would one determine the angle created from three points, such as those > above? All of the suggested scripts seem quite long. Try putting this script into three buttons. The script uses the Other Mark's way of dragging the button around (and it doesn't hilite the button as he claims): on mouseDown repeat until the mouse is up with messages set the loc of me to the mouseLoc wait 0 millisecs with messages end repeat put 180 - angler(loc of btn 1,loc of btn 2,loc of btn 3)/pi*180 end mouseDown function angler p1, p2, p3 put atan2(item 2 of p2-item 2 of p1,item 1 of p2 - item 1 of p1) into angle1 put atan2(item 2 of p3-item 2 of p2,item 1 of p3 - item 1 of p2) into angle2 return abs(angle2-angle1) end angler The bit that calculates the angle could be done in a single line: put 180 - (atan2(item 2 of p3-item 2 of p2,item 1 of p3 - item 1 of p2)-atan2(item 2 of p2-item 2 of p1,item 1 of p2 - item 1 of p1))/pi*180 ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
On Dec 16, 2009, at 11:01 AM, Colin Holgate wrote: > > All of the suggested scripts seem quite long. Correction, gmc's solution was also using atan2, and was fairly short. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
Message: 24 Date: Tue, 15 Dec 2009 22:21:47 -0800 From: Mark Swindell Subject: Deriving an angle from three points To: How to use Revolution Message-ID: Content-Type: text/plain; charset=us-ascii 40,116 98,186 132,118 How would one determine the angle created from three points, such as those above? Thanks, Mark Mark, Or even easier. Set the Turtle at the apex and get the angle of the other two points. on mouseUp startTurtle --Initiates the turtle graphics library penup setxy 98,186 --The vertex put direction(40,116) into A put direction(132,118) into B put B-A into dA put abs(dA) & cr & abs(180 - dA) into msg box choose the browse tool end mouseUP (Assuming your middle point is the apex of the angle you want.) To run this you will need the TG library. Run this in the msg box go url "http://www.jamesphurley.com/jhurleyFolder/TurtleGraphics.rev"; Jim Hurley ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
Mark- Wednesday, December 16, 2009, 6:08:16 AM, you wrote: > The above represents roughly a V shape with the center point the > vertex. It doesn't. Three points in a plane represents a triangle. -- -Mark Wieder mwie...@ahsoftware.net ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
gmccarthy- Wednesday, December 16, 2009, 2:07:46 AM, you wrote: > By the way again, Mark's method is also correct if you fix the variable names > as shown below. > Normally a triangle with points ABC have their sides named with side b > between A and C so it is opposite angle B...etc. Quite correct. In my defense, it was one in the morning here after a long day... -- -Mark Wieder mwie...@ahsoftware.net ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
Well, of course it's a triangle, but describing it as a V helped explain which angle was wanted. On Dec 16, 2009, at 1:25 PM, Mark Wieder wrote: It doesn't. Three points in a plane represents a triangle ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
No it didn't. On Dec 16, 2009, at 10:44 AM, Colin Holgate wrote: > Well, of course it's a triangle, but describing it as a V helped explain > which angle was wanted. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
On 12/16/09 10:57 AM, Bruce Robertson wrote: No it didn't. On Dec 16, 2009, at 10:44 AM, Colin Holgate wrote: Well, of course it's a triangle, but describing it as a V helped explain which angle was wanted. I thought Mark S identified it well when he called it the 'internal angle' - at least that did it for me: On Dec 15, 2009, at 10:35 PM, Mark Wieder wrote: > Mark- > > Tuesday, December 15, 2009, 10:21:47 PM, you wrote: > >> 40,116 >> 98,186 >> 132,118 > >> How would one determine the angle created from three points, such as those above? > > There are three angles. Which one are you interested in? > > --- The above represents roughly a V shape with the center point the vertex. I was trying to detemine the internal angle. -- Phil Davis PDS Labs Professional Software Development http://pdslabs.net ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
On Wed, Dec 16, 2009 at 6:56 PM, Jacques Hausser wrote: > I really should re-read my mails before sending them :-( > I cannot copy and paste scripts directly into mails (I don't know why) so I > rewrite them... with bugs ! > > Now that Mark has his solution, this seems to be the next thing that needs solving. What platform are you on and which email client do you use? Are your scripts in Rev or tRev? Does it make a difference if you use your mouse and select Copy and Paste rather than using keyboard shortcuts? Can you Copy and Paste code from Rev into a text editor or other program, or from one Rev script to another Rev script, ie is the problem you can't Copy in Rev, you can Copy but it get's lost when going to some other programs, or Paste just never works outside of Rev? This was an intermitant problem with Rev way back and the usual cure was to manually select the menu commands. HTH ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
James, Thanks for this, but starting the Turtle stack did not allow me to calculate the angle. I got an error each time at "Start Turtle." Is there a trick to making the library accessible to other stacks? Mark On Dec 16, 2009, at 8:08 AM, James Hurley wrote: >> >> Message: 24 >> Date: Tue, 15 Dec 2009 22:21:47 -0800 >> From: Mark Swindell >> Subject: Deriving an angle from three points >> To: How to use Revolution >> Message-ID: >> Content-Type: text/plain;charset=us-ascii >> >> 40,116 >> 98,186 >> 132,118 >> >> How would one determine the angle created from three points, such as those >> above? >> >> Thanks, >> Mark >> > > Mark, > > Or even easier. Set the Turtle at the apex and get the angle of the other two > points. > > > on mouseUp > startTurtle --Initiates the turtle graphics library > penup > setxy 98,186 --The vertex > put direction(40,116) into A > put direction(132,118) into B > put B-A into dA > put abs(dA) & cr & abs(180 - dA) into msg box > choose the browse tool > end mouseUP > > (Assuming your middle point is the apex of the angle you want.) > > To run this you will need the TG library. Run this in the msg box > > go url "http://www.jamesphurley.com/jhurleyFolder/TurtleGraphics.rev"; > > Jim Hurley > ___ > use-revolution mailing list > use-revolution@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
Colin, Thanks, this appears to be a very succinct solution. Very much appreciated. Mark On Dec 16, 2009, at 8:01 AM, Colin Holgate wrote: > > On Dec 16, 2009, at 1:21 AM, Mark Swindell wrote: > >> 40,116 >> 98,186 >> 132,118 >> >> How would one determine the angle created from three points, such as those >> above? > > > All of the suggested scripts seem quite long. Try putting this script into > three buttons. The script uses the Other Mark's way of dragging the button > around (and it doesn't hilite the button as he claims): > > on mouseDown >repeat until the mouse is up with messages > set the loc of me to the mouseLoc > wait 0 millisecs with messages > end repeat > put 180 - angler(loc of btn 1,loc of btn 2,loc of btn 3)/pi*180 > end mouseDown > function angler p1, p2, p3 > put atan2(item 2 of p2-item 2 of p1,item 1 of p2 - item 1 of p1) into angle1 > put atan2(item 2 of p3-item 2 of p2,item 1 of p3 - item 1 of p2) into angle2 > return abs(angle2-angle1) > end angler > > The bit that calculates the angle could be done in a single line: > > put 180 - (atan2(item 2 of p3-item 2 of p2,item 1 of p3 - item 1 of > p2)-atan2(item 2 of p2-item 2 of p1,item 1 of p2 - item 1 of p1))/pi*180 > > > ___ > use-revolution mailing list > use-revolution@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
Thank you to all who provided code suggestions and insight into solving this problem (James, Colin, Mark W. gMc, Pierre, Jacques, Phil). I'd have taken forever to figure this out without such a helpful (and clever) bunch of allies. Mark On Dec 16, 2009, at 1:57 AM, gmccarthy wrote: > > What about getting the angle from point B to A, then the angle from point B > to C, then getting the difference: > > on mouseUp > put cd fld "A" into pointA > put cd fld "B" into pointB -- assumed center of angle > put cd fld "C" into pointC > -- > put fGetAngle(pointB, pointA) into angleA > put fGetAngle(pointB, pointC) into angleC > if angleC > angleA then > put angleC - angleA into cd fld "AngleABC" > else > put angleA - angleC into cd fld "AngleABC" > end if > end mouseUp > > function fGetAngle pPoint1, pPoint2 > --angle anticlockwise from X axis > return atan2(item 2 of pPoint2 - item 2 of pPoint1,item 1 of pPoint2 - > item 1 of pPoint1) * 180 / pi > end fGetAngle > > > See atan2 in the dictionary. > By the way, this gives 66.209226 for the angle. > > As a test for known angles, try > 250,250 > 200,200 > 100,373 > This is for angles of 45 degrees and 120 degrees. > you should get 75 degrees as your answer. > -- > View this message in context: > http://n4.nabble.com/Deriving-an-angle-from-three-points-tp964930p965051.html > Sent from the Revolution - User mailing list archive at Nabble.com. > ___ > use-revolution mailing list > use-revolution@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
Message: 12 Date: Wed, 16 Dec 2009 21:47:10 -0800 From: Mark Swindell Subject: Re: Deriving an angle from three points To: How to use Revolution Message-ID: <3ceb9dd4-d059-43b4-8a77-2f4e86c48...@cruzio.com> Content-Type: text/plain; charset=us-ascii James, Thanks for this, but starting the Turtle stack did not allow me to calculate the angle. I got an error each time at "Start Turtle." Is there a trick to making the library accessible to other stacks? Mark Mark, I think the problem might be that you may have used "Start Turtle" instead of "StartTurtle" There should be no spaces. Try just copying and pasting the script into a button on the Turtle Graphics stack. If you use it outside of the Turtle Graphics stack, you will need to do a "Start Using stack..." Hope this helps. Jim Hurley On Dec 16, 2009, at 8:08 AM, James Hurley wrote: Message: 24 Date: Tue, 15 Dec 2009 22:21:47 -0800 From: Mark Swindell Subject: Deriving an angle from three points To: How to use Revolution Message-ID: Content-Type: text/plain; charset=us-ascii 40,116 98,186 132,118 How would one determine the angle created from three points, such as those above? Thanks, Mark Mark, Or even easier. Set the Turtle at the apex and get the angle of the other two points. on mouseUp startTurtle --Initiates the turtle graphics library penup setxy 98,186 --The vertex put direction(40,116) into A put direction(132,118) into B put B-A into dA put abs(dA) & cr & abs(180 - dA) into msg box choose the browse tool end mouseUP (Assuming your middle point is the apex of the angle you want.) To run this you will need the TG library. Run this in the msg box go url "http://www.jamesphurley.com/jhurleyFolder/TurtleGraphics.rev"; Jim Hurley ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Deriving an angle from three points
Thanks. I neglected to include the "start using" command. Mark On Dec 17, 2009, at 11:18 AM, James Hurley wrote: >> >> Message: 12 >> Date: Wed, 16 Dec 2009 21:47:10 -0800 >> From: Mark Swindell >> Subject: Re: Deriving an angle from three points >> To: How to use Revolution >> Message-ID: <3ceb9dd4-d059-43b4-8a77-2f4e86c48...@cruzio.com> >> Content-Type: text/plain; charset=us-ascii >> >> James, >> >> Thanks for this, but starting the Turtle stack did not allow me to calculate >> the angle. I got an error each time at "Start Turtle." Is there a trick to >> making the library accessible to other stacks? >> >> Mark > > Mark, > > I think the problem might be that you may have used "Start Turtle" instead of > "StartTurtle" > > There should be no spaces. Try just copying and pasting the script into a > button on the Turtle Graphics stack. If you use it outside of the Turtle > Graphics stack, you will need to do a "Start Using stack..." > > Hope this helps. > > Jim Hurley >> >> On Dec 16, 2009, at 8:08 AM, James Hurley wrote: >> >>>> >>>> Message: 24 >>>> Date: Tue, 15 Dec 2009 22:21:47 -0800 >>>> From: Mark Swindell >>>> Subject: Deriving an angle from three points >>>> To: How to use Revolution >>>> Message-ID: >>>> Content-Type: text/plain; charset=us-ascii >>>> >>>> 40,116 >>>> 98,186 >>>> 132,118 >>>> >>>> How would one determine the angle created from three points, such as those >>>> above? >>>> >>>> Thanks, >>>> Mark >>>> >>> >>> Mark, >>> >>> Or even easier. Set the Turtle at the apex and get the angle of the other >>> two points. >>> >>> >>> on mouseUp >>> startTurtle --Initiates the turtle graphics library >>> penup >>> setxy 98,186 --The vertex >>> put direction(40,116) into A >>> put direction(132,118) into B >>> put B-A into dA >>> put abs(dA) & cr & abs(180 - dA) into msg box >>> choose the browse tool >>> end mouseUP >>> >>> (Assuming your middle point is the apex of the angle you want.) >>> >>> To run this you will need the TG library. Run this in the msg box >>> >>> go url "http://www.jamesphurley.com/jhurleyFolder/TurtleGraphics.rev"; >>> >>> Jim Hurley >>> ___ >>> use-revolution mailing list >>> use-revolution@lists.runrev.com >>> Please visit this url to subscribe, unsubscribe and manage your >>> subscription preferences: >>> http://lists.runrev.com/mailman/listinfo/use-revolution >> > > > > > > ___ > use-revolution mailing list > use-revolution@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
copying scripts [was: Deriving an angle from three points]
Le 17 déc. 2009 à 01:33, Kay C Lan a écrit : > On Wed, Dec 16, 2009 at 6:56 PM, Jacques Hausser > wrote: > >> I really should re-read my mails before sending them :-( >> I cannot copy and paste scripts directly into mails (I don't know why) so I >> rewrite them... with bugs ! >> > > Now that Mark has his solution, this seems to be the next thing that needs > solving. Hi Kay, It is rather rare that I try to copy scripts and paste them on mails, so I didn't care for a solution. I can live without - as long as I do not post bugs ;o). After reading your post this morning, I checked the process just after opening Rev... and it works OK ! When I tried yesterday, I was editing and testing scripts for some hours, using relatively large amounts of memory (12 megapixel images). I didn't copy or paste them, however. I try to answer your questions as far as I remember: > What platform are you on and which email client do you use? Are your scripts > in Rev or tRev? Mac OS 10.6.2 - Apple's Mail - Rev Enterprise > Does it make a difference if you use your mouse and select Copy and Paste > rather than using keyboard shortcuts? Not sure - I probably used the shortcut. "Paste" was dimmed in Mail. But not in TextEdit (see below) ! > Can you Copy and Paste code from Rev into a text editor or other program, or > from one Rev script to another Rev script, ie is the problem you can't Copy > in Rev, you can Copy but it get's lost when going to some other programs, or > Paste just never works outside of Rev? Yes, I tried after sending my last mail - scripts pasted in TextEdit without problems, either in txt or in RTF. It seems it was something not recognized by Mail in the clipboard... I didn't check other programs. Last precision: the default format for my Mail is set to text only. > This was an intermitant problem with Rev way back and the usual cure was to > manually select the menu commands. I remember too well - specially boring for cmd E ! Well, I'll check again after some hours on RunRev... but still, it is not a vital problem ! Jacques ** Prof. Jacques Hausser Department of Ecology and Evolution Biophore / Sorge University of Lausanne CH 1015 Lausanne please use my private address: 6 route de Burtigny CH-1269 Bassins tel/fax:++ 41 22 366 19 40 mobile: ++ 41 79 757 05 24 E-Mail: jacques.haus...@unil.ch *** ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Can't Paste? (Was copying scripts/Deriving an angle from three points)
You can't paste? Is it that the pasted text comes over with all its styles? (the script editor is filled with color) If so, the size of the mail increases dramatically, and it is stopped by Rev's own defences. I always change copied scripts to plain old text before pasting: function plainText tText repeat for each char theChar in tText put numToChar(charToNum(theChar)) after temp end repeat return temp end plainText I set up a functionKey to process anything already in the clipboard. So I copy, Fkey and paste. Or is it something more sinister? I mean, pasting, already. That is like breathing. Anyone have a better way? You cannot set the textStyle or HTMLText of a string in a variable. Craig Newman In a message dated 12/17/09 5:16:57 AM, jacques.haus...@unil.ch writes: > I cannot copy and paste scripts directly into mails (I don't know why) so > I > >> rewrite them... with bugs ! > ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution