#### Archived

This topic is now archived and is closed to further replies.

# aargh! What am I doing wrong?

This topic is 5624 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This is the equation I have... I need to rearrange it so I just have k = .... max_angle = tan(k)*2; Am I missing something stupid, because I get... k = tan^-1 (max_angle * 2); where tan^-1 is the inverse. It doesn''t seem to be working as I expected in my program, and figured this simple thing must be the problem. perhaps I am calculating the inverse tan wrong in C... Am I right in thinking inverse tan is atan in the math.h library? Maybe I''m right and the answer lies somewhere else. ugh! Thanks for any help.

yes

##### Share on other sites
Actually, the equation I get is...

k = tan^-1 (max_angle / 2);

oops, I messed up the multiply/divide by 2 bit... but it''s still not working as expected.

##### Share on other sites
k = arctan(max_angle / 2)

##### Share on other sites
atan(max_angle / 2)

##### Share on other sites
Uhh, if Y = 2tan(X), wouldn't X = tan-1(Y/2)?

[edited by - zealouselixir on May 3, 2003 7:32:55 PM]

##### Share on other sites
quote:
Original post by Hybrid
oops, I messed up the multiply/divide by 2 bit... but it''s still not working as expected.

In that case, perhaps you''d like to share with us what exactly you''re trying to do. We''re assuming for your sake that you''re converting to radians if your k is in degrees here.

##### Share on other sites
Why is the variable called max_angle? You shouldn''t get an angle out of a tangent function. It should be the triangle height/width. Also, the arctan function will probably only return an angle between -pi/2 and +pi/2, so depending on what you are doing, you may have to adjust the value.

##### Share on other sites
Thanks for the replies. Yeah, I am converting to radians...

This is for a cone particle emitter. It uses some code I found on the net. ''k'' determines the spread of the cone (the angle, though its more of a coefficient than an angle), and that max_angle = tan(k) * 2 gives you the maximum cone angle given a k value, and I''m trying to work out the k value need to set the max_angle to what I want. So I can define my cone emitter using an angle rather than some k value which makes no sense when looking at it.

You''ll find the maths on this page... with the max_angle =... if you scroll down a bit...

http://www.hut.fi/~vhelin/particles.txt

Thanks

##### Share on other sites
In C++, if you want angle k to be in degrees when you solve for it, this would be the equation to use (assuming max_angle is also in degrees):

k = atan( (max_angle / 2) * (pi/180.0f) );

If you want k in radians (assuming max_angle is in radians):

k = atan( max_angle / 2);

The function atan() obtains the arctan of a given angle (in radians), which is equivalent to tan^(-1).

If you want a more accurate result, use atanf() instead.

NOTE: pi = 3.14159265358979 (double)

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 10
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632647
• Total Posts
3007640
• ### Who's Online (See full list)

There are no registered users currently online

×