dragon
dragon

Reputation: 317

Draw line using its angle and radius in iphone

I want to draw line from one point to another unknown point.I want to find this unknown point using its angle and radius from current point. Then i want to draw between these two points as line..

Can anyone help me?

Thanks in advance...

Note:

I already used these method

x2 = x1 - length * cos(angle)
y2 = y1 - length * sin(angle)

But these found point is not correct for some angle...

Upvotes: 1

Views: 460

Answers (1)

Marcelo Cantos
Marcelo Cantos

Reputation: 185862

Some things to check:

  1. The use of - and + after ... = x1 and ... = y1 depends on the angular coordinate system you want to use. Make sure you've got this right.
  2. Likewise cos and sin may need to be swapped.
  3. Is angle in radians? If it's in degrees, it won't work.

Note that I'm not suggesting you have points 1 and 2 wrong. It's impossible to say without knowing how you want your geometry to function, and what coordinate system you're using. Plus, the iPhone SDKs are a bit schizophrenic in this regard.

Upvotes: 1

Related Questions