Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Trigonometry with pic.rotate help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
david92ng




PostPosted: Sat May 10, 2008 8:17 pm   Post subject: Trigonometry with pic.rotate help

we have one point (x,y) and we have an other point(x2,y2)

x,y is the center.
lets say x2 and y2 is some random point around the center.

now the question, i want to draw a picture at the center(x,y) and after i will use pic.rotate it so it will point to x2,y2.
To do that i somehow need the angle from the center to the other point.

i totally forgot Trigonometry which i know i need to use for this. can someone give me the formula?
thanks
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Sat May 10, 2008 9:49 pm   Post subject: Re: Trigonometry with pic.rotate help

Merry Christmas!
Turing:

fcn getAngle(x1, y1, x2, y2 : real) : real
    /*Some code shamelessly stolen from Bored*/
    var opp := y2 - y1
    var adj := x2 - x1
    if adj = 0 then
        if y2 > y1 then
            result 90
        else
            result 270
        end if
    elsif opp >= 0 and adj > 0 then
        result arctand (opp / adj)
    elsif adj < 0 then
        result 180 + arctand (opp / adj)
    elsif opp < 0 and adj > 0 then
        result 360 + arctand (opp / adj)
    end if
end getAngle


Just pass in the coordinates of your two points.
david92ng




PostPosted: Sat May 10, 2008 10:50 pm   Post subject: Re: Trigonometry with pic.rotate help

thanks. works great.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: