Simple trigonometry / geometry question. Diagram included

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
5 replies · 3K views
rekshaw
Messages
15
Reaction score
0
Hey all,

BACKGROUND: (please note that knowledge of this is not necessary):
I'm currently writing a javascript application using vectors (with jquery and raphaeljs) that enables me to rotate custom text (using font.js file, not normal fonts). However, due to a bug in the new version of raphael, when I rotate a text made up of multiple letters, all the letters rotate on their own relative center.

Don't worry, I'm not asking you to help me debug my scripting language, I'm asking you to help me get around this bug by manually calculating the translating movements (x and y) of each letter.

If I wasn't clear until now, don't worry, I'll show you exactly what I need (quick photoshop):

MATHEMATICAL PROBLEM:

[PLAIN]http://img534.imageshack.us/img534/1780/rotationtranslation.png

Variables I know:

- the angle a
- the angles b
- the 2 sides K

I need to find the blue and orange (y and x) lengths in order to translate my letters properly.
 
Last edited by a moderator:
Mathematics news on Phys.org
Quick reply: find the cartesian location of every letter, switch to polar, rotate them the desire angle, switch back to cartesian
 
gsal said:
Quick reply: find the cartesian location of every letter, switch to polar, rotate them the desire angle, switch back to cartesian
gsal's answer is probably what you really want but, to literally answer your question, what you're looking for is the cosine law...
 
Length of side opposite to angle a, = 2Ksin(a/2) ; for small a it will approximate to K.a (a in radian ) Let, say this side "Black"
Since,"Orange" line is perpendicular to "Blue". Orange, Blue and Black line form Pythagorean triangle. So the problem is reduced to finding the Pythagorean triplet. Length of Black line, l(Black) is already known, now we need to find, l(Orange) and l(Blue).

Length of Black line, l(Black) = 2Ksin(a/2). Now if l(Black) is not an integer, then divide l(Black) by a rational number "k", such that l(Black)/k is an integer. Let call this number "B".

If B is odd then, other two numbers of Pythagorean triplet are P1 = B2/2 - 1/2 and P2 = P1+1

If B is even then, other two numbers of Pythagorean triplet are P1 = B2/4 - 1 and P2 = P1+2

Now, l(orange), l(Blue) = kP1 , kP2 ( if kP1 > kP2 then l(Blue) = kP1 and l(orange)= kP2 otherwise l(Blue) = kP2 and l(orange)= kP1)
 
As far as I can tell, you don't need the angle b.

The blue side is [itex]K \ \sin \left(a\right)[/itex]. The orange part is [itex]K \ \left(1-\cos\left(a\right)\right)[/itex].

You'll see that in your diagram, if you switch the blue line over you can make a right triangle with K as the hypotenuse. This means that sin(a) * k = the blue line.

You'll also notice that the other leg of the right triangle with hypotenuse K is cos(a) * k. Subtracting this from your length K gives you the length of your orange section.
 
Consider this:
You have an isosceles triangle
You know the measures of it's angles
You know the lengths of it's legs
You know the length of it's base

What you DON'T know is the angle that the triangle makes with either the vertical or horizontal translation lines.

In other words, you could rotate the triangle, keeping the same physical qualities as the original one, which would change the lengths of those translation lines.
Therefore, each line independently has the potential for having a length ranging from zero to the same length as the base of the triangle.