Shadowrun: Awakened 29 September 2011 - Build 871
Functions
coordsys.cpp File Reference
#include "machine.h"
#include "types.h"
#include "coordsys.h"
Include dependency graph for coordsys.cpp:

Go to the source code of this file.

Functions

void xytopolar (flt x, flt y, flt rad, flt *u, flt *v)
void xyztocyl (vector pnt, flt height, flt *u, flt *v)
void xyztospr (vector pnt, flt *u, flt *v)

Function Documentation

void xytopolar ( flt  x,
flt  y,
flt  rad,
flt u,
flt v 
)

Definition at line 68 of file coordsys.cpp.

References TWOPI.

                                                        {
  flt r1;
  r1=x*x + y*y;  
  *v=sqrt(r1 / (rad*rad));
  if (y<0.0) 
    *u=1.0 - acos(x/sqrt(r1))/TWOPI;
  else 
    *u= acos(x/sqrt(r1))/TWOPI; 
}
void xyztocyl ( vector  pnt,
flt  height,
flt u,
flt v 
)

Definition at line 78 of file coordsys.cpp.

References TWOPI, vector::x, vector::y, and vector::z.

Referenced by cyl_checker_texture(), and image_cyl_texture().

                                                        {
  flt r1;

  r1=pnt.x*pnt.x + pnt.y*pnt.y;

  *v=pnt.z / height;
  if (pnt.y<0.0) 
    *u=1.0 - acos(pnt.x/sqrt(r1))/TWOPI;
  else 
    *u=acos(pnt.x/sqrt(r1))/TWOPI;
}
void xyztospr ( vector  pnt,
flt u,
flt v 
)

Definition at line 90 of file coordsys.cpp.

References TWOPI, vector::x, vector::y, and vector::z.

Referenced by image_sphere_texture().

                                            {
  flt r1, phi, theta;
 
  r1=sqrt(pnt.x*pnt.x + pnt.y*pnt.y + pnt.z*pnt.z);

  phi=acos(-pnt.y/r1);   
  *v=phi/3.1415926;

  theta=acos((pnt.x/r1)/sin(phi))/TWOPI;

  if (pnt.z > 0.0) 
    *u = theta;
  else 
    *u = 1 - theta; 
}

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net