How to solve this trig function?

Started by
20 comments, last by lawnjelly 5 years, 8 months ago

sin(a*t) * d = sin(a*(1-t)) * e

 

I want to solve for t, t has to be in range [0,1], and all other values are known.

Using math tools they only spit out special and disallowed cases (I don't know how to use them properly for periodic stuff).

Graphing both sides of the equation, both sides are simple sine waves and any intersection would be my solution. But so far i only know how to add 2 waves, not how to find intersections. Maybe somebody has a quick answer while i try from there...

Advertisement

You just need to look up trig identities and apply them to simplify and solve the problem.

Harder than i thought and probably too expensive for the inner loop of a solver for UV maps.

I ended up at the same point few days ago but noticed there was a simple geometric solution to get around it. It should work in a similar way too this time i hope...

I did some napkin calculations, and found below result. Not 100% sure, so verify before using:


t = 1/a.( atan( ( d + e.cos(a) ) / e.sin(a) ) ) ) 

Assuming you know a, d and e and can calculate arc tan relatively easily. 

12 hours ago, fmatak said:

I did some napkin calculations, and found below result. Not 100% sure, so verify before using:



t = 1/a.( atan( ( d + e.cos(a) ) / e.sin(a) ) ) ) 

Assuming you know a, d and e and can calculate arc tan relatively easily. 

Thanks, but seems wrong.

You forgot a brace, i tried those options, but they are both wrong:


float a = 1.3f;
float d = 0.7f;
float e = 0.9f;

// try to solve
// sin(a*t) * d = sin(a*(1-t)) * e
// for t

{
	float t = 1 / a * ( atan( ( d + e*cos(a) ) / e*sin(a) ) );
	float proofLHS = sin(a*t) * d;
	float proofRHS = sin(a*(1-t)) * e;
	ImGui::Text ("(1) lhs %f != rhs %f", proofLHS, proofRHS);
}
{
	float t = 1 / (a * ( atan( ( d + e*cos(a) ) / e*sin(a) ) ) );
	float proofLHS = sin(a*t) * d;
	float proofRHS = sin(a*(1-t)) * e;
	ImGui::Text ("(2) lhs %f != rhs %f", proofLHS, proofRHS);
}
{
	static float t = 0.573;
	ImGui::DragFloat("t", &t, 0.0001f);

	float proofLHS = sin(a*t) * d;
	float proofRHS = sin(a*(1-t)) * e;
	ImGui::Text ("(3) lhs %f != rhs %f", proofLHS, proofRHS);
}

output:

(1) lhs 0.496743 != rhs 0.440162 (small error but with other numbers it's large)
(2) lhs 0.668042 != rhs 0.029278
(3) lhs 0.474529 != rhs 0.474325

 

I've had no luck myself yet either...

 

I'm absolutely rubbish at maths but this is as far as I got:

sin(a*t) * d = sin(a*(1-t)) * e

sin(a*t) = (sin(a*(1-t)) * e) / d

sin(a*t) / sin(a*(1-t)) = e / d

Then I went to this site:

http://www.webmath.com/trigsimp.html

and found that

sin(a*t) / sin(a*(1-t)) is the same as sin(ta)

so

sin(ta) = e/d

So in my vast maths ability I've managed to make the equation smaller lol. :D

Whooo! I'll take a look... :D

Meanwhile manages to get something from Wolfram alpha - it just did not work because it does not like variable name 'e' i guess, sigh :)

http://www.wolframalpha.com/input/?i=Solve+Sin[z*t]+*+x+%3D+Sin[z*(1-t)]+*+y+for+t

Quote

(from the website)

sin(a*t) / sin(a*(1-t)) is the same as sin(ta)

this can't be right, I think that site is confusing, as that's just the numerator... grr!! :( Here's some more gibberish from the site, perhaps it is just trying to say that a*t is the same as ta, wow, I could have guessed that lol.

Quote

The problem to solve is:

sin(a*t) / sin(a*(1-t))

 

Multiply t and a

Multiply the t and a

Multiply t and a

 

The t just gets copied along.

The a just gets copied along.

The answer is ta

ta

a*t evaluates to ta

sin(a*t)/sin(a*(1-t)) evaluates to sin(ta)

If all else fails it looks like you can have a 2d lookup table with a and e/d! :)

5 hours ago, JoeJ said:

You forgot a brace, i tried those options, but they are both wrong

Sorry, I copied from the napkin and forgot to add correct braces. Here you go:


t = ( 1 / a ) * ( atan( ( d + e * cos(a) ) / ( e * sin(a) ) ) ) ) )

The problem was with the last sin, it should be in the braces as well..

I gradually felt like I was getting there with some trig identities but I haven't tried solving equations since school 30 years ago lol

Would you mind showing how you got to that step by step fmatak, for the benefit of us mathematically challenged folk lol... :D

 

 

This topic is closed to new replies.

Advertisement