Results 1 to 3 of 3

Thread: Some Trig

  1. #1
    Zaei
    Guest
    I want to find the angle between 2 points. For
    example, i am at point (1,2), and i want to be at (8,6).
    First i need to rotate X degrees, until i face my
    destination, then move N spaces, until i am there.

    So, to make a right triangle, i take Point1.Y (2) and
    Point2.X (8) to form the right angle at (8,2). Any
    algorithm for this?

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Check out my sample rotation using guv's safe arctangent function:
    http://forums.vb-world.net/showthrea...threadid=53924
    If you want to rotate 90 degrees you switch dx and dy as follows:
    to the left
    x = cx + dy
    y = cy - dx
    to the right
    x = cx - dy
    y = cy + dx
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Guest
    I figured it out last night, but thanks kedaman. =)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width