-2

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.

Lokesh
  • 829
  • 2
  • 14
  • 26
  • Can you show what you have already tried so far to solve the problem? – Darin Dimitrov Aug 23 '10 at 06:12
  • I have tried the solution posted in the below thread. http://stackoverflow.com/questions/3536428/draw-a-line-at-a-specific-angle-in-java Here they dint bother about the diagonal line,but in my above query i need to calculate the point based on my diagonal line length. – Lokesh Aug 23 '10 at 06:24

1 Answers1

6

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
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953