Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Algorithm for orientation of a 2d vector?

Name: Anonymous 2008-07-20 19:40

Hey; I was wondering if there is a simple algorithm that takes an x and y value (the values of the vector), and returns the angle between north and the vector, clockwise? All that I learned in trig class back in school has left me, and Google isn't giving me anything useful.

Name: Anonymous 2008-07-20 19:50

I'm willing to figure it out myself if someone will point me to some similar "angle from 2d vector" code; it doesn't have to match my 'clockwise from north' specifics.

Name: Anonymous 2008-07-20 19:50

Google isn't giving me anything useful.
It sure did give me. I'm looking right now at the solution to your problem, which was the third result using some very obvious search terms.

Name: Anonymous 2008-07-20 19:51

atan2

Also, whatever you are trying to navigate will fail miserably.

Name: Anonymous 2008-07-20 19:51

why don't you take another vector that points "north" and then, liek, totally use trigonometry and shit?

Name: Anonymous 2008-07-20 19:56

>>4
Aha! I knew there had to be a function like that. Thanks!

>>5
Because I'm not so great with trig.

Name: Anonymous 2008-07-20 19:57

Name: Anonymous 2008-07-20 21:00

>>6
How can you not be great with trig? Are circles a problem for you?

Name: Anonymous 2008-07-20 21:31

>>8
And so what if I am? I embraced my circumphobia a long time ago, etc.

Name: Anonymous 2008-07-21 0:01

Wow you are a FAILURE

Whatever you are trying to use vectors fail will suck.  I am guessing it has to do with games/3d if so just STOP and go learn instead.

Name: Anonymous 2008-07-21 0:33

Anyway the way you do this is you have the vector in question.  Take it's magnitude and normalize it.  Once normalized now you project it onto the Y axis.  Do this multiply it by a function that discards X.  Once this is done you do a COS lookup and the value is the degrees.

Name: Anonymous 2008-07-21 0:51

a COS lookup

Name: Anonymous 2008-07-21 1:14

>>12

well I was just fucking around

cos(theta) = magnitude Y-component of a normalized vector.

I was just fucking around but you get the picture its not too hard you fuck

Name: Anonymous 2008-07-21 16:02

OP you're probably doing it wrong. You should avoid trig functions like fire.
>>13
I am awed by your knowledge of linear algebra.

Name: Anonymous 2008-07-21 16:44

Go west, where the skies are blue

Name: Anonymous 2008-07-21 16:50

>>14
I am awed by your knowledge of linear algebra.
Er, this is something that anyone who took trig should know. And it's wrong anyway. He's mixed it up with sine.

Name: Anonymous 2008-07-21 19:16

>>16
I think he derived that from the formula for the dot product of  vectors a and b where b is a unit vector.

Name: Anonymous 2008-07-29 7:55

>>16
It's not wrong you dumbfuck!!!!
Goddamn why do


    member v.DegreesFromNorth
       with get() =
          let z = acos(currDY/v.Length) * 57.2957795
          if (currDX > 0.0) then z
          else 360.0 - z

Name: Anonymous 2008-07-29 7:59

>>18
is normalized

Name: Anonymous 2008-07-29 7:59

>>19
disregard that, I did this when 4chan went down so yeah

Name: Anonymous 2008-07-29 8:55

   |    ,.ゝ─-,.r'´ ̄ `丶、       |  Big penis-san
    ヽ,.r'"   ,. / ヽ `ヽ--─ '"フ     |
   /  ,.' /  il i ヽ 丶   ,.イ    |   Very good programming nya~
 ,.イ/  /i /l   !| l   ヽ l,..ノ,. 'i    |
  /ィ / /-ノ、l  ハ ! ! : l i/j l |    ノノ ̄ ̄ ̄ ̄ ̄ ̄ ̄
  ! l/ ,ir‐‐、 iヽl -ヽl、 l !│ / ,' !
   )r'! i l;;ソ   ‐r‐、,ソ,.j / / /,ィ      ,. -‐- 、
  '´ l |  '     j.:.::ゞj /、 / // i     / ,. -、 ヽ
    l lヽ  l>  `'‐'"//ッノ ! ハ! `   /  , '   ヽ ゙!
   ,.-l 、ゝ、 __ ,.  ‐'フ,' ミ,.| j |     ,'  /    j  l
  /  ` シ;.    "'ツ'´  ,シヽ' `'    |  l    ノ! ,.ヘ
  !   ,.ゞヘ;.j、ハ.r;.iゞ'ミ'゙   `丶、   l  '、    '"'´
  l l / /  ヽ   ヽ      ヽ   ヽ 丶
  ヽ,i'  , '   > '´ ヽ   ヽ、     j    ヽ、 ヽ
  /  '、 ,.'   ,ノ   リ     ,ヘ、    ヽ ヽ
  !   ヽj  ,. '"      !    l  ヽ、. --、._ j  !
  丶   `'´       ノ‐--- '!        〉i`ヾ、
    ヽ...,, -- 、..    ,. '"|     j      / ,'   ヽ
     ト、 ヽi ゙;,,.シ ̄;ゞ  l    ,'l     ,.' ノ-'"  丶
    〉、  l `''"^'''"´ ̄|     l、..__,. -' =‐- 、.._   i
     | 丶. !   ,. ‐ ' ´l   、l,. - ‐ '" ̄ `丶、 ` |
     |   l ,. '´    l     !             ヽ j
    !  /      ,. !   │          /
    l. , '         /  l     l             ,.'
     ,!'       /    l    |           /
   /        , '      l   |     ,. ‐'´
   !      /         !,.=ゝ_,. -‐' ´
   !     ,'        ,j    ヽ‐ 、"""''' ─-- ....
   丶、    l      イl l   、ヽ丶,j
     ` ‐- ' ヽ      j ! j /^ヽヽヽl

Name: Anonymous 2008-07-29 11:06

>>19
If it's normalized you can get rid of the v.Length Division.

Name: Anonymous 2008-07-29 11:55

>>22 please see >>18-20

Name: Anonymous 2010-11-13 10:27

Name: Anonymous 2010-12-21 19:17

Don't change these.
Name: Email:
Entire Thread Thread List