It is currently Fri May 26, 2017 2:02 pm

All times are UTC - 5 hours




 Page 1 of 1 [ 2 posts ] 
Author Message
 Post subject: Math VMK 8 - Spherical Coordinate System
PostPosted: Mon Jan 14, 2008 10:15 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
The workings of the spherical coordinate system are explained and the three parameters: r, theta, phi are related to the standard cartesian x,y,z coordinates.


Offline
 Profile  
 
 Post subject: Random point on the sphere - a faster way.
PostPosted: Mon Dec 22, 2008 4:26 pm 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
If someone wants a random point on the sphere, there is a quite effective way. It is possible to calculate only 3 (transcendental) functions:
sin( theta ), cos( theta ), sqrt( ), instead of 4 ones: sin( theta ), cos( theta ), sin( phi ), cos( phi ). Here it is.
    const float z = Rand::get( -1.0f, 1.0f ); // get random float point in range [-1.0, +1.0]
    const float t = Rand::get( 0.0f, F_2PI ); // get random float point in range [ 0.0, 2 * PI]
    const float r = sqrt ( 1 - z * z ); // square root
    const float x = r * cos ( t );
    const float y = r * sin ( t );
   
    m_points.push_back( Point3( RADIUS * x, RADIUS * y, RADIUS * z ) );


...........Image...........


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron