21 lines
No EOL
452 B
Text
21 lines
No EOL
452 B
Text
/*
|
|
contributors: [Ivan Dianov, Kathy McGuiness]
|
|
description: cartesian to polar transformation.
|
|
use: <float2|float3> cart2polar(<float2|float3> st)
|
|
*/
|
|
|
|
#ifndef FNC_CART2POLAR
|
|
#define FNC_CART2POLAR
|
|
|
|
float2 cart2polar(float2 st) {
|
|
return float2(atan2(st.y, st.x), length(st));
|
|
}
|
|
|
|
float3 cart2polar( float3 st ) {
|
|
float r = length(st);
|
|
float theta = acos(st.z/r);
|
|
float phi = atan2(st.y, st.x);
|
|
return float3(r, theta, phi);
|
|
}
|
|
|
|
#endif |