1 /* bzflag
2  * Copyright (c) 1993-2021 Tim Riker
3  *
4  * This package is free software;  you can redistribute it and/or
5  * modify it under the terms of the license found in the file
6  * named COPYING that should have accompanied this file.
7  *
8  * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
9  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
10  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11  */
12 
13 #ifndef BZF_RAY_H
14 #define BZF_RAY_H
15 
16 #include "common.h"
17 #include <string.h> // for memset()
18 
19 /** Encapsulates a semi-infinite ray. */
20 
21 class Ray
22 {
23 public:
24     Ray();
25     Ray(const float* o, const float* d);
26     Ray(const Ray&);
27     ~Ray();
28     Ray&        operator=(const Ray&);
29 
30     const float*    getOrigin() const;
31     const float*    getDirection() const;
32     void        getPoint(float t, float p[3]) const;
33 
34 private:
35     float       o[3];
36     float       d[3];
37 };
38 
39 //
40 // Ray
41 //
42 
Ray()43 inline Ray::Ray()
44 {
45     memset(o,0,sizeof(float)*3);
46     memset(d,0,sizeof(float)*3);
47 }
48 
~Ray()49 inline Ray::~Ray()
50 {
51     // do nothing
52 }
53 
getOrigin()54 inline const float* Ray::getOrigin() const
55 {
56     return o;
57 }
58 
getDirection()59 inline const float* Ray::getDirection() const
60 {
61     return d;
62 }
63 
64 #endif // BZF_RAY_H
65 
66 // Local Variables: ***
67 // mode: C++ ***
68 // tab-width: 4 ***
69 // c-basic-offset: 4 ***
70 // indent-tabs-mode: nil ***
71 // End: ***
72 // ex: shiftwidth=4 tabstop=4
73