source: golgotha/src/i4/math/point.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 1.3 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#ifndef __POINT_HH_
10#define __POINT_HH_
11
12#include "arch.hh"
13#include "math/vector.hh"
14
15class i4_3d_point_class : public i4_3d_vector
16{
17public:
18  i4_3d_point_class() {}
19  i4_3d_point_class(const i4_3d_vector &p) : i4_3d_vector(p) {}
20  i4_3d_point_class(i4_float _x, i4_float _y, i4_float _z) : i4_3d_vector(_x, _y, _z) {}
21
22  i4_3d_point_class& operator=(const i4_3d_vector &p) { set(p.x,p.y,p.z); return *this; }
23
24  i4_bool almost_equal(i4_3d_point_class &a, i4_float error=0.001)
25  {
26    return (i4_bool)
27      ((i4_fabs(x - a.x)<error) &&
28          (i4_fabs(y - a.y)<error) &&
29          (i4_fabs(z - a.z)<error));
30  }
31
32  i4_float distance(const i4_3d_point_class &other)
33  { return sqrt( (x-other.x)*(x-other.x) + (y-other.y)*(y-other.y) + (y-other.y)*(y-other.y)); }
34};
35
36#endif
37
Note: See TracBrowser for help on using the repository browser.