| Ultrashock Forums
• [Math] Rectangle Problem |
|||
![]() |
||||
| Search this Thread | Thread Tools | Display Modes |
|
|
|||||||||||||||||||||||||
![]() |
Ultrashock Member Comments:
|
2008-03-13
#2 |
||
|
|
2008-03-13
#3 |
||
|
pretty good job andy, thanks. what if i'm given A, B and theta and im solving for x and y? other way around. that would be impossible right?
|
|
|
2008-03-13
#4 |
||
|
It's possible to do. You'd just rearrange this: cos(t) = adjacent/hypotenuse = A1/x so now it's x = A1/cos(t). Of course you'll either need A1 or you'll end up having four equations and four unknowns. You'll then need to solve them with a matrix. |
|
|
2008-03-13
#5 |
||
|
yep, would need a1. you mean linear equations?
|
|
|
2008-03-13
#6 |
||
|
Hmm well thinking it through, it's possible to figure out, but not pretty. Essentially you'll have to work off these equations: A = A1 + A2 = x*cos(t) + y*sin(t) B = B1 + B2 = y*cos(t) + x*sin(t) which will give you: A1 + A2 = something B1 + B2 = something however there's not enough information right there. So then you have to add extra equations such as: A1^2 + B2^2 = x^2 A2^2 + B1^2 = y^2 Then solve for all four equations: A1 + A2 = x*cos(t) + y*sin(t) B1 + B2 = y*cos(t) + x*sin(t) A1^2 + B2^2 = x^2 A2^2 + B1^2 = y^2 Now actually this is where I was wrong before: it's not linear for the last two equations so you can't easily use matrices (or systems of LINEAR equations). I would actually solve it using a greedy algorithm from there (i.e. guess and check). |
|
17 Creative Assets
|
2008-03-13
#7 |
||
|
I have a cheatsheet in my blog that covers a lot of the basic trigonometry, and it is geared towards use in Flash. |
|
|
2008-03-14
#8 |
||
|
thanks nutrox and andy for helping
|
|
|
2008-03-14
#9 |
||
|
Code:
x = (Bsin(t)) - (Acos(t)) / (sin^2(t) - cos^2(t)) |
|
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|



8 comments
| 970 views



17 Creative Assets
Linear Mode
A is the sum of the lengths of the longer edge of one triangle and the shorter edge of the other. B uses the other edges.
So essentially you're going to need to solve for all of the smaller triangles (which is only two or four lengths since two sides are known).
Since you know x and y, we can apply Pythagorean. I'll refer you to a tutorial I wrote in my blog: http://www.ultrashock.com/blog/andy-...inates-30.html
If you use some geometry, you'll find that the smaller triangles are just scaled down versions of the bigger one. i.e. the angles should all be the same: theta, 90-theta, and 90.
Anyway in short I will combine the lengths from two triangles and I should get formulas like this (I'll represent theta as t):
A = A1 + A2 = x*cos(t) + y*sin(t)
B = B1 + B2 = y*cos(t) + x*sin(t)
Where A1 and A2 represent two parts of A as defined by the triangle. The same is with B.
I'm able to arrive at the first term for the equation for A by:
cos(t) = adjacent/hypotenuse = A1/x. Rearrange this to get A1 = x*cos(t). Repeat for other 3 terms.