home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / gamesystem / source / gs_vector.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-09  |  843 b   |  41 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    gsCVector
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    12/03/00
  8. //
  9. // Base:    gsCObject
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #include "gamesystem.h"
  16.  
  17. //-------------------------------------------------------------
  18.  
  19. gsCVector gsCVector::polar(float distance,float angle)
  20. {
  21.     return gsCVector(distance * gsSin(angle),
  22.                      distance * -gsCos(angle));
  23. }
  24.  
  25. //-------------------------------------------------------------
  26.  
  27. void gsCVector::clamp(float minx,float maxx,float miny,float maxy)
  28. {
  29.     if (m_x < minx)
  30.         m_x = minx;
  31.     if (m_x > maxx)
  32.         m_x = maxx;
  33.     if (m_y < miny)
  34.         m_y = miny;
  35.     if (m_y > maxy)
  36.         m_y = maxy;
  37. }
  38.  
  39. //-------------------------------------------------------------
  40.  
  41.