Computing heading
Colin Putney
cputney at wiresong.ca
Sun Jan 4 17:54:03 UTC 2004
On Jan 4, 2004, at 9:34 AM, David T. Lewis wrote:
> On Sun, Jan 04, 2004 at 12:41:19AM 0800, Jack Johnson wrote:
>> I was messing around with EToys and grabbed an arrow morph and a
>> couple
>> of ellipses and wanted to have the arrow morph automatically place
>> itself between the two ellipses and point from one to the other.
>>
>> The placement was easy, but I had trouble computing the heading. I
>> did
>> come across a formula used for computing a bearing based on two map
>> coordinates:
>>
>> tc1=mod(atan2(sin(lon1lon2)*cos(lat2),cos(lat1)*sin(lat2)
>> sin(lat1)*cos(lat2)*cos(lon1lon2)),2*pi)
>>
>> which would work just fine, but being relatively new to Squeak I'm at
>> a
>> loss for how to implement it, or how to even find out if/how Squeak
>> implements the atan2 function.
>>
>> Any pointers or suggestions?
>>
>> Jack
>
> Hi Jack, welcome to Squeak.
>
> Bert gave you a good answer for the problem you are trying to solve,
> but as a
> newcomer to Squeak you may also be interested in knowing "how do I
> write
> this math formula in Squeak?". To answer that, I'm going to drop down
> a level
> into the Smalltalk language that is working underneath the EToys
> envinroment.
Hi Jack,
Just in case you're more interested in the diagram than the math, I'd
also suggest having a look at Ned Konz' Connectors package. It's very
good at dealing with ellipses connected by arrows.
The Connectors page is here: <http://minnow.cc.gatech.edu/squeak/1773>.
You can install Connectors via SqueakMap, which is explained here:
<http://minnow.cc.gatech.edu/squeak/2726>.
Have fun!
Colin
More information about the Squeakdev
mailing list
