Trig problem for practical use

This topic has expert replies
Newbie | Next Rank: 10 Posts
Posts: 2
Joined: Sat Jan 17, 2009 1:20 pm
Location: Amsterdam NL

Trig problem for practical use

by boops boops » Sat Jan 17, 2009 2:32 pm
Hi everyone, I'm an artist with a penchant for programming, and I'm interested in creating new computer drawing tools for artists in VB.Net. At the moment I'm trying to create a tool for smoothed freehand drawing. I've come up against a geometry/problem that maybe someone here can help me with. People on the programming forums I've tried so far seem to be too thick to answer this.

Suppose there are three points A (= Xa, Ya), B (=Xb, Yb) and C (Xc, Yc). I can work out the angle A^BC by calculating the slope of AB and subtracting slope of BC. I can calculate the slopes of lines AB and BC using ArcTan. So far, no problem.

Now if angle ^B is too acute, less than bLimit degrees, I want to move point B towards the line AC to make the angle A^B'C equal to bLimit degrees. My question is: what is the new position of point B'?

To sum up, I have the coordinates of the corners of a triangle A, B and C. Where on the perpendicular from B to AC must I put the new point B' such that angle A^BC is equal to a given angle bLimit? I can work out the lengths a, b and c and the angles of the original triangle ABC and so on, so the answer can be in terms of those.

Any takers? I'll be very grateful if you can help.

Regards, Boops boops.


Image

GMAT/MBA Expert

User avatar
GMAT Instructor
Posts: 2621
Joined: Mon Jun 02, 2008 3:17 am
Location: Montreal
Thanked: 1090 times
Followed by:355 members
GMAT Score:780

Re: Trig problem for practical use

by Ian Stewart » Sun Jan 18, 2009 6:28 am
That's a two coffee problem. I changed notation to get rid of the subscripts while I solved it, and I'll use my notation here to make my life easier: let the co-ordinates of A be (A, a), of B be (B, b), and of C be (C, c). We want to find a point (D, d) which:
  • lies on the perpendicular to AC which passes through B
  • gives us a predetermined angle Blimit at ADC
If you just steam ahead and try to solve for D and d, you'll end up in an algebraic mess - you'll find you have a fraction with about thirty terms in it. Co-ordinate geometry becomes a lot easier if you're dealing with horizontal and vertical lines. To solve the general problem, it will be easiest to do the following:
  • Translate all our points (by subtracting A from each x co-ordinate and a from each y co-ordinate) so that point A is at (0,0)
  • Rotate all our points about (0,0) = A, so that point C lies on the x axis. That is, we have translated point C so it is now at (C - A, c - a). If the slope of AC is positive, then the line AC will form an angle of arctan( (c-a) / (C-A) ) with the x -axis; we want to rotate all our points by that angle. I'll assume you have a rotation function implemented.
  • We then solve the problem in the translated and rotated situation.
  • Finally, we just need to reverse our rotation and translation to get our solution back to the original situation.
So, we can assume that (A, a) = (0,0), that (C, c) = (C, 0), and that D = B, so (D, d) = (B, d).

We need to find d so that (D, d) gives us the correct angle. At the point where two lines with slopes m and n meet, the smaller (acute, so < 90 degree) angle formed at their intersection point is given by:

tan(Theta) = | (m - n)/(1 + mn) |

Now, I'm guessing, given your setup, that the angle you've called Blimit will be greater than 90 degrees. If that's the case, then the Theta in the formula above is not equal to Blimit; instead, Theta is going to be equal to 180 - Blimit.

The slopes m and n that we are concerned with here are:

m = slope of DA = d/D = d/B
n = slope of DC = d/(B - C)

so we have:

tan(Theta) = | ( (d/B) - (d/(B - C)) )/(1 + (d/B)(d/(B - C)) ) |

tan(Theta) = | [( -dC)/(B(B-C))] / [( B(B-C) + d^2)/(B(B-C)) ] |

and thankfully we get some cancellation:

tan(Theta) = | (dC)/(B^2 - CB + d^2) |

By our assumption above that Blimit is greater than 90 degrees, 1 + mn will be positive, so we should have:

tan(Theta) = dC/(B^2 - CB + d^2)

If Blimit is less than 90, you'd want to introduce a negative sign on the right side of the equation. Now, tan(Theta) is a known value; I'll call it T for simplicity:

T(B^2 - CB + d^2) = dC

(T)d^2 - (C)d + TB^2 - TBC = 0

Every number here is known besides d; we can use the quadratic formula to find d:

d = (C +/- sqrt(C^2 - 4T(TB^2 - TBC)) )/2T

You'll presumably want to choose the positive solution if the slope of AB is positive:

d = (C + sqrt(C^2 - 4BT^2(B - C)) )/2T

Notice that this is certain to have a solution if 0 < B < C; under the root we have C^2 - 4B (tan^2 (theta))(B-C); C^2 is positive, and B-C is negative, so 4B (tan^2 (theta))(B-C) must be negative; since we are subtracting a negative from a positive, we are certain to have a positive value under the root. Just remember that T = tan(Theta) = tan(180 - Blimit); the angle Theta is not the same as Blimit, if Blimit > 90 degrees.

Now that we have d, we just need to rotate, then translate, (D, d) back into the position of the original diagram, and we're done.

There's quite a few steps in the above, but I just checked that it works for one set of numbers, so I'm pretty sure everything is correct.
For online GMAT math tutoring, or to buy my higher-level Quant books and problem sets, contact me at ianstewartgmat at gmail.com

ianstewartgmat.com

Newbie | Next Rank: 10 Posts
Posts: 2
Joined: Sat Jan 17, 2009 1:20 pm
Location: Amsterdam NL

by boops boops » Sun Jan 18, 2009 11:29 am
Hi Ian,

I am sure I can use your formula in trying out different curve smoothing approaches. (Spline curves alone won't cut it. They're so ... well, spliny.)

Rotating and translating the coordinates won't be a problem, but I will have to figure out how to deal with Blimit angles all round the clock - above and below the "horizontal" and potentially obtuse as well as acute. First, I am going to have to find some time to look at your derivation. Probably I will get there but if not I may call again!

A mere buttonclick thankyou doesn't do justice to the effort you have gone to. Once again, thanks and warm regards,
Vic Joseph
(aka Boops boops)

GMAT/MBA Expert

User avatar
GMAT Instructor
Posts: 2621
Joined: Mon Jun 02, 2008 3:17 am
Location: Montreal
Thanked: 1090 times
Followed by:355 members
GMAT Score:780

by Ian Stewart » Sun Jan 18, 2009 12:58 pm
Good luck with the project, Vic - it was an interesting little math problem and it's a pleasure to work on something here that might have artistic application. If you do use the above and find it's not giving the correct result, the mistake is likely mine - there could be an issue with minus signs in the different scenarios that you mention. The method is certainly right, though, so it would be easy to track down any error or modify the formula to suit a different configuration of points. Feel free to send me a personal message if I can be of any further help.
For online GMAT math tutoring, or to buy my higher-level Quant books and problem sets, contact me at ianstewartgmat at gmail.com

ianstewartgmat.com