A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: equation solved. how to?

  1. #1
    Member
    Join Date
    Jul 2001
    Posts
    32
    hey you little math-helpers out there

    i'd really appreciate your help with this one.
    probably not hard if you just know how to.

    i need to have either one of these equations solved for 'd':


    I : f = cos(d) * x + sin(d) * z
    II : e = -sin(d) * x + cos(d) * z


    easy?

    thanks in advance - marc

  2. #2
    Senior Member
    Join Date
    Mar 2002
    Posts
    183
    Quick question about it.

    Is "d" a constant or the variable for sin/cos. So, for example, if d=2, would it read:
    f = cos(2)*x (constant?) + sin(2)*z (constant?)
    or:
    f = cos(2x) + sin(2z)
    I am thinking you are referring to the last one here, but just to be sure....

  3. #3
    Member
    Join Date
    Jul 2001
    Posts
    32
    oopsidaisy - wasn't clear, was it?

    i meant the first one, like:

    f = (cos alpha) * x + (sin alpha) * z
    e = -(sin alpha) * x + (cos alpha) * z

    where f,x,z are known, nad i want to know alpha.


    a friend of mine just brought up this one:

    alpha = arcsin( - ((e - f*z) / (x^2 - z^2)))

    didn't give it a try yet, i'm eating right now, but i'll post any positive results.
    meanwhile, if you come up with something...

  4. #4
    Senior Member
    Join Date
    Mar 2002
    Posts
    183
    I have been thinking about this for a little bit now, and honestly, I am kinda stumped. What is this for? I am undergrad engineer, and I haven't ever had a problem like this. I am sure that it is possible, but the thing is that it has 3 variables in it. I have not yet studied equations with 3 variables. I will ask my prof though. Maybe she will be able to figure it out. Actually, I will e-mail her right now for ya. If the equation read:
    f = cos(dx) + sin(dx) I would be able to do it for you, but with that damn "z" in there, I can't do it. Hopefully I can get an answer for you though.

  5. #5
    Senior Member
    Join Date
    Mar 2002
    Posts
    183
    Hm....I have been looking at your friend's, and I am not sure. The only thing that I have a problem with is the cos in the original equation. It seems to "disappear" in the final one. There are a few cos identities, but those all still contain a cos in them. I am not sure though, if he knows what he's doing, then go for it.

  6. #6
    Senior Member
    Join Date
    Jan 2002
    Posts
    368
    as posted on another board...

    it looks like he's rotating point x,y around 0,0 at an angle of d, resulting in point e,f. trying to find the angle.

    to restate the situation...

    get angle from 0,0 to x,y:

    Math.atan2(y,x)

    get angle from 0,0 to e,f:

    Math.atan2(f,e)

    subtract those two angles and you will have the amount of the rotation d.

  7. #7
    Member
    Join Date
    Jul 2001
    Posts
    32
    and hello again, bit-101...

    (sorry for wild-posting around - was still trying to figure out your post and didn't get to clean up behind me. already after midnight here in central europe, been at it a long time today, blabla...)

    anyway.

    i have this feeling, that i won't get far with your angle on my angle.
    of course you're right, i'm trying to find the angle that my point was rotated by. more specific: i have 6 points on a ball, which are rotating just fine by themselves. easy, that.
    if you rollOver a point you start to use the whole thing like a track ball, meaning, you control the motions of the points by moving the rolledOver point.
    my problem is: the radius of the ball is 250(px). now you move the point by, say, 10px horizontally. if the point happens to be near the balls equator, this would mean rotating the whole thing (all points) about 5 degrees or so around the y-axis. but if the point is almost at one of the poles it would mean something rather like 50 or 60 degrees.
    see what i mean?
    does your thing cover that?

    i'm *trying* to understand, but i'm just learning as i go along (and i've come a long way, baby...)

    best regards

    __________________
    @ minger

    thanks a lot for putting your mind to my problem.
    of course i have this little mistake in the above post:
    not only f,x,z are known, but also e.
    one thing less to worry about...
    [Edited by marc.hm on 04-08-2002 at 06:51 PM]

  8. #8
    Gross Pecululatarian Ed Mack's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    2,954
    Could you do a 2d hitTest on the points, and then just go into trackball mode, store the last x/y of the mouse, add the difference of the new ones to the angles, and store the new x/y? Might have a bit of a problem with the point not moving at the same time, though it's more simple

  9. #9
    Member
    Join Date
    Jul 2001
    Posts
    32
    nah Ed_Mack,

    don't want it simple, i want it good.
    if i got it right what you meant, there would be just the problem as said above. or the other way around:

    if i rotate the ball horizontally by 20 degrees, a point on the equator would move a looong way (say from Austin,Texas to Miami) whereas a point at the pole would just move a teenyweeny bit (remember those barrels at the northpole, all in circle...just a few steps really, but you'd freezy your ass off).
    man, sorry, i'm talking like you're daft or something. i guess i'm just tired enough to turn off the coffee maker and...
    but you get the problem? the amount of pixel you move mean different angles on different areas on the ball/globe

  10. #10
    Senior Member
    Join Date
    Mar 2002
    Posts
    183
    Oh, I didn't know that those others were known. Cause here is what my professor said about it in the way that I thought.

    Michael:

    This is tough! If the sine and cosine had the same argument, one could square both sides of the equation. Then the cos^2+sin^2 would be 1, and the 2*sin*cos could be written as a sin by the double-angle formula, so that eventually an application of the inverse sine would be possible.

    But with different arguments ...? I don't know whether that's possible!

    Two questions that might help to solve the problem (if not the equation):
    1) Is the equation really needed in this generality? (Perhaps there are other conditions on the variables/constants? Are they all representing arbitrary real numbers, or are some of them integers?)
    2) Is it really necessary to solve the equation for a? (In which connection did this problem come up? Maybe a different approach would be the best way to go?)

    Sorry, that's all I can come up with right now! --SWS

    PS: Let me know of the outcome!


    Yeah, but I will try her again with the fact that those other things are known. Hopefully she will be able to help, she is pretty smart. If Bit has the way to do it without solving that equation (he does seem to know just about everything ) then you can go his way, otherwise, I will continue to try and solve this.

  11. #11
    Junior Member
    Join Date
    Apr 2002
    Posts
    1
    try doing this:
    Substitute cos(d) and sin(d) with C and S
    Solve eq I for S giving S = (f-Cx)/z
    Substitute this for S in eq II giving e = (Cx-f)x/z+Cz
    Solve for C giving C = (fx+ez)/(xx+zz)
    Replace C with cos(d) and solve for d giving d = acos((fx+ez)/(xx+zz)) this should work. One of the problems with solving these equations is that its over specified. 2 equations for 1 unknown.

  12. #12
    Member
    Join Date
    Jul 2001
    Posts
    32
    allright, thanks everybody for helping me out here.
    i really really REALLY appreciate all the pain you've gone through with my question.

    right now, though, i'm working on a solution, which mathematicaly isn't quite as elegant, but i'll be able to work it out by myself, which is always a bit more satisfying.
    however, when i'm through with it and have a little time to breathe, i'll try to work out a way based on these equations and your solutions.

    as soon as i have it worked out i'll let you know.

    so, thanks again, it's the way to go...

    *marc

  13. #13
    Member
    Join Date
    Feb 2002
    Posts
    79
    I worked it out and realized I got the same thing as awelynant.

    alpha = arccos((fx+ez)/(z^2+x^2))
    alpha = arcsin((fz-ex)/(z^2+x^2))

    those should be the same if your values for e,d,z and x are valid.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center