Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
423 views
in Technique[技术] by (71.8m points)

c# - How to calculate the point(x2,y2) with the point (x1,y1) and the angle

Again i came back with a question.

1.I have a line drawing from a point (x2,y2) for which i do no the end point(Say point unknown as in the fig),but i knew the line length and the angle from the vector (x2,y2). Can any one help me how to calculate the unknown points.

alt text

Thanks, Lokesh.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This looks like a job for ... Trigonometry-man.

Consider the following diagram:

          /|
         /B|
        /  |
       /   |
      /    |
   c /     | a
    /      |
   /       |
  /       _|
 /A      |C|
*----------+
      b

You know the angle B, it's 45o. You also know C is 90o because that's the "right angle" bit of the right angle triangle.

And, because the angles inside a triangle add up to 180o, angle A must also be 45o.

You also know the length of the hypotenuse c. With trigonometry(a), you can get the lengths of the other two sides with:

a = c sin A
b = c cos B

Then simply add those to your starting point (making sure you get the signs right) and you have your ending point.

For example, let's say your hypotenuse was 1.414213562, a number I just just picked at random off the top of my head :-)

The length a is c sin A or 1.414213562 * sin 45, which is 1.414213562 * 0.707106781 or 1.

Wow, what were the chances of that? :-)


(a) My children reminded me of the "soh cah toa" (pronounced so car toe ah) rule, where "opposite" and "adjacent" sides are location from the angle X:

soh : sin X = opposite / hypotenuse
cah : cos X = adjacent / hypotenuse
toa : tan X = opposite / adjacent

          /|
         / |
        /  |
       /   |
      /    |
 hyp /     | opp
    /      |
   /       |
  /       _|
 /X      | |
*----------+
     adj

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...