1,599 reputation
927
bio website klaimsden.net
location France
age 31
visits member for 4 years, 3 months
seen 2 days ago

Making games with my bare hands. Building narratives with my forehead.


Jul
31
awarded  Notable Question
Jul
20
awarded  Yearling
Jul
2
awarded  Curious
May
31
comment What are the pros and cons of HLSL vs GLSL vs cg?
@NicolBolas That part was added but I'm not the author. I couldn't find any link at the time but there is apparently an effective lack of update of CG so I guess it was true. Also it looks like APIs will change again soon, so...
Feb
11
awarded  Nice Question
Feb
7
awarded  Popular Question
Jan
26
comment Spherical coordinate from cartesian coordinate
Thanks. I'll not to never again try to do maths at 2am in the morning...
Jan
26
comment Spherical coordinate from cartesian coordinate
After having use this code, I found that there is an issue: when I ask for from_cartesian( UNIT_X ) I get a phi which is negative (-90degree) while I should have a positive value (270degree). This I believe makes my unit tests get very wrong. I have no idea how to fix this.
Dec
12
accepted Spherical coordinate from cartesian coordinate
Dec
6
comment Spherical coordinate from cartesian coordinate
It my mistake again, I did atan2( y, hypot(x,z)) instead of atan2( hypot(x,z), y). Now it seems to work almost perfectly. The problem I see is positions around negative Z being avoided (I'm using a moving cursor using the spherical coordinates to check visually). I think the issue might be related to a chain of transformations I'm doing, I'm checking that right now.
Dec
6
comment Spherical coordinate from cartesian coordinate
Howver, my problem don't seem to be really fixed yet.
Dec
6
comment Spherical coordinate from cartesian coordinate
It don't seem to work either. I'm not sure where is the problem.
Dec
6
comment Spherical coordinate from cartesian coordinate
My mistake, I assumed that radius was already the value of hypot(x,z). I'll try that right now.
Dec
6
comment Spherical coordinate from cartesian coordinate
It helps understanding the issue, but not fully, because it was not clear to me how to work around the sign and pi thing. I learnt about atan2 which apparently does the work efficiently.
Dec
6
comment Spherical coordinate from cartesian coordinate
Ok now I think I get it. I try the following code: SphereVector result = SphereVector::ZERO; result.radius = cartesian.length(); if( result.radius == 0 ) return result; result.phi = Math::ATan2( cartesian.z, cartesian.x ); result.theta = Math::ACos( cartesian.y / result.radius ); return result; It seems to be working except for positions close to negative Z which seems to be buggy, but it might be something else in my code that's wrong.
Dec
6
comment Spherical coordinate from cartesian coordinate
this is helpful, however "atan2(hypot(x,z), y)" don't seem to be correct. Did you mean acos? Because it seem to be the right equation.
Dec
6
comment Spherical coordinate from cartesian coordinate
I follow the explaination except the last line which contain the answer. What do you mean by which quarter? I assume that the "pole" is +Y, so what you seem to mean is that when theta is out of valid range I should add nPi, n being either 0.5, 1, 1.5 or 2? Not sure I understand correctly.
Dec
6
asked Spherical coordinate from cartesian coordinate
Sep
3
awarded  Popular Question
Aug
24
answered How to use C++11 chrono header for a clock