J
johnnash
In my project I need to shoot rays from the source.I know you cannot
follow all the rays from the source as you can actually shoot rays at
infinite angles,therefore my plan is to launch rays from the
trasmitter in all directions spaced eg. x degrees or something. This
is the logic I have used for a C program -
consider the source to be centre of the unit sphere.
0<=theta<=180(zenith)
0<=phi<=360 (azimuth)
Then run a for loop like this -
for( theta = 0 ; theta <=180; theta = theta + 5 ) /* taking some 5
degree difference or there will be infinite rays */
for( phi = 0; phi <=360; phi = phi + 5 )
{
/*Calculate the cartesian coordinates of a point p(a struct) on
sphere*/
P.x = r*sin(theta)*cos(phi);
P.y = r * sin(theta) *sin(phi);
P.z = r * cos(theta);
direction[index] = VectorSubtract(P, Center_of_Sphere);
VectorNormalize(direction[index]);
/*direction is just a list that will store ray directions */
follow all the rays from the source as you can actually shoot rays at
infinite angles,therefore my plan is to launch rays from the
trasmitter in all directions spaced eg. x degrees or something. This
is the logic I have used for a C program -
consider the source to be centre of the unit sphere.
0<=theta<=180(zenith)
0<=phi<=360 (azimuth)
Then run a for loop like this -
for( theta = 0 ; theta <=180; theta = theta + 5 ) /* taking some 5
degree difference or there will be infinite rays */
for( phi = 0; phi <=360; phi = phi + 5 )
{
/*Calculate the cartesian coordinates of a point p(a struct) on
sphere*/
P.x = r*sin(theta)*cos(phi);
P.y = r * sin(theta) *sin(phi);
P.z = r * cos(theta);
direction[index] = VectorSubtract(P, Center_of_Sphere);
VectorNormalize(direction[index]);
/*direction is just a list that will store ray directions */