GL Studio API
vertex.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::Vertex class. A class for manipulating 3D vertices.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2015 by The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 #ifndef _VERTEX_H
41 #define _VERTEX_H
42 
43 #include "disti_include.h"
44 #include "display_types.h"
45 #include "gls_color.h"
46 #include "unhide_globals.h"
47 
48 #include <iosfwd> //Forward references for the stream operators
49 #include <math.h>
50 
51 #ifndef M_PI
52 #define M_PI 3.14159265358979323846
53 #endif
54 
55 // DEG_TO_RAD Converts degrees to radians
56 #ifndef DEG_TO_RAD
57 #define DEG_TO_RAD (M_PI/180.0)
58 #endif
59 
60 namespace disti
61 {
62 
63 class Vertex;
64 class VertexNoColor;
65 
66 /** This typedef is a changed from pre 3.0 versions.
67  * Now Vector is different from Vertex. It now contains no color
68  * information
69  */
70 typedef VertexNoColor Vector;
71 
72 /** Rotation axis enumeration. Passed into rotation calls */
73 typedef enum
74 {
75  X_AXIS, /**< Rotate around the X Axis */
76  Y_AXIS, /**< Rotate around the Y Axis */
77  Z_AXIS /**< Rotate around the Z Axis */
78 } RotationAxis;
79 
80 /**
81  The Vertex class: Implements a 3D cartesian coordianate and operations
82  for manipulating them.
83 */
85 {
86  public:
87 
88  float x,y,z;
89 
90  /** Simple constructor. Ensures all values are initialized */
91  inline VertexNoColor() :
92  x(0.0f),
93  y(0.0f),
94  z(0.0f)
95  {}
96 
97  /** Position only constructor. Color values are set to defaults
98  \param _x The X value of the vertex, in logical units
99  \param _y The Y value of the vertex, in logical units
100  \param _z The Z value of the vertex, in logical units */
101  inline VertexNoColor(float _x,float _y,float _z) :
102  x(_x),
103  y(_y),
104  z(_z)
105  {}
106 
107  /** Compute the square of the cartesian distance between this point and
108  another one , in 3D
109  \param v The vertex to compute distance squared to
110  \return The square of the distance between the two points */
111  inline float Distance3Squared(const VertexNoColor &v) const
112  { return ((v.x-x)*(v.x-x)) + ((v.y-y)*(v.y-y)) + ((v.z-z)*(v.z-z)); }
113 
114  /** Returns the squared distance of this point from the line defined by start
115  and direction, in 3D
116  \param startx starting x coordinate of the line.
117  \param starty starting y coordinate of the line.
118  \param startz starting z coordinate of the line.
119  \param direction Normalized direction vector for the line.
120  \return the distance from this point. */
121  inline float DistanceFromLineSquared(const float startx, const float starty, const float startz, const VertexNoColor &direction) const
122  {
123  // Distance from point to line
124  // Algorithm from Mgc::SqrDistance http://www.magic-software.com/License/free.pdf
125 
126  VertexNoColor kDiff(x, y, z);
127 
128  //kDiff = rkPoint - linePoint;
129  kDiff.x -= startx;
130  kDiff.y -= starty;
131  kDiff.z -= startz;
132 
133  float fSqrLen = direction.MagnitudeSquared();
134  float fT = kDiff.DotProduct(direction)/fSqrLen;
135 
136  //kDiff.minusAssign(direction.multiply(fT));
137  kDiff.x -= direction.x * fT;
138  kDiff.y -= direction.y * fT;
139  kDiff.z -= direction.z * fT;
140 
141  float dist_squared = kDiff.MagnitudeSquared();
142 
143  return dist_squared;
144  }
145 
146  /** Compute cartesian distance between this point and another one , in 3D
147  \param v The vertex to compute distance to.
148  \return The distance between the two points */
149  inline float Distance3(const VertexNoColor &v) const
150  { return float(sqrt( ((v.x-x)*(v.x-x)) + ((v.y-y)*(v.y-y)) + ((v.z-z)*(v.z-z)))); }
151 
152  /** Compute the square of the cartesian distance between this point and
153  another one , in 2D
154  \param v The vertex to compute distance squared to
155  \return The square of the distance between the two points */
156  inline float Distance2Squared(const VertexNoColor &v) const
157  { return ((v.x-x)*(v.x-x))+ ((v.y-y)*(v.y-y)); }
158 
159  /** Compute cartesian distance between this point and another one , in 2D
160  \param v The vertex to compute distance to
161  \return The distance between the two points */
162  inline float Distance2(const VertexNoColor &v) const
163  { return float(sqrt(((v.x-x)*(v.x-x))+ ((v.y-y)*(v.y-y)))); }
164 
165  /** Compute the result of adding this point to another one, in 3D
166  \param arg The vertex to add to this one
167  \return A new vertex V2 where V2 = this + v */
168  inline VertexNoColor operator + (const VertexNoColor &arg) const
169  { return VertexNoColor(x + arg.x,y + arg.y,z + arg.z); }
170 
171  /** Negation operator */
172  inline VertexNoColor operator - () const
173  { return VertexNoColor(-x,-y,-z);}
174 
175  /** Compute the result of multiplying this point by a scalar
176  \param s The Scalar to multiply by
177  \return A new vertex V2 where V2 = this * s */
178  inline VertexNoColor operator * (const float s) const
179  { return VertexNoColor(x*s,y*s,z*s); }
180 
181  /** Compute the result of multiplying this point by a scalar
182  \param s The Scalar to multiply by
183  \return V = V * s */
184  inline VertexNoColor& operator *= (const float s)
185  { x *= s; y *= s; z *= s;
186  return *this; }
187 
188  /** Compute the result of dividing this point by a scalar
189  \param s The Scalar to divide by
190  \return A new vertex V2 where V2 = this / s */
191  inline VertexNoColor operator / (const float s) const
192  { return VertexNoColor(x/s,y/s,z/s); }
193 
194  /** Compute the result of dividing this point by a scalar
195  \param s The Scalar to divide by
196  \return V = V / s */
197  inline VertexNoColor& operator /= (const float s)
198  { x /= s; y /= s; z /= s;
199  return *this; }
200 
201  /** Compute the result of adding this point to another one, in 3D
202  \param arg The vertex to add to this one
203  \return V = V + arg */
205  { x += arg.x; y += arg.y; z += arg.z;
206  return *this; }
207 
208  /** Compute the result of subtracting this point from another one, in 3D
209  \param arg The vertex to subtract from this one
210  \return A new vertex V2 where V2 = this - v */
211  inline VertexNoColor operator - (const VertexNoColor &arg) const
212  { return VertexNoColor(x - arg.x,y - arg.y,z - arg.z); }
213 
214  /** Compute the result of subtracting this point from another one, in 3D
215  \param arg The vertex to subtract from this one
216  \return V = V - arg */
218  { x -= arg.x; y -= arg.y; z -= arg.z;
219  return *this; }
220 
221  /** Determines if the vertex is identical to the supplied vertex, ignoring color
222  \param arg vertex to compare to
223  \return TRUE if equal, else FALSE
224  */
225  inline bool operator == (const VertexNoColor &arg) const
226  { return ((x == arg.x) && (y == arg.y) && (z == arg.z)); }
227 
228  /** Determines if the vertex is identical to the supplied vertex, ignoring color
229  \param arg vertex to compare to
230  \return TRUE if equal, else FALSE
231  */
232  inline bool operator != (const VertexNoColor &arg) const
233  { return ((x != arg.x) || (y != arg.y) || (z != arg.z)); }
234 
235  /** Computes the result of muliplying this point to another one.
236  \param arg vertex to multiple with
237  \return resulting vertex
238  */
239  inline VertexNoColor operator * (const VertexNoColor &arg) const
240  {
241  return VertexNoColor(x * arg.x,y * arg.y,z * arg.z);
242  }
243 
244  /** Rotate this point in 2D clockwise around the z axis.
245  \param angle The angle to rotate around, in degrees.
246  \return The rotated vertex */
247  DISTI_EXPORT VertexNoColor Rotate(const float angle) const;
248 
249  /** Rotate this point around a different point in 2D counter-clockwise around the z axis.
250  \param orig The rotation origin to rotate around.
251  \param angle The angle to rotate around, in degrees.
252  \return The rotated vertex */
253  DISTI_EXPORT VertexNoColor Rotate(const VertexNoColor &orig,const float angle) const;
254 
255  /** Rotate this point around a different point in 2D clockwise around the z axis.
256  \param orig The rotation origin to rotate around.
257  \param angle The angle to rotate around, in degrees.
258  \param axis The axis to rotate around. See RotationAxis enum.
259  \return The rotated vertex */
260  DISTI_EXPORT VertexNoColor Rotate(const VertexNoColor &orig,const float angle,const int axis) const;
261 
262  /** Rotate this vertex by angle theta counter-clockwise around an arbitrary axis r.
263  \param orig The rotation origin to rotate around.
264  \param angle The angle to rotate around, in degrees.
265  \param r The axis to rotate around.
266  \return The rotated vertex
267  */
268  DISTI_EXPORT VertexNoColor Rotate(const VertexNoColor &orig, const float angle, const Vector &r) const;
269 
270  /** Normalizes the vector into a unit vector */
271  inline void Normalize(void)
272  {
273  float length, inv_length;
274 
275  length = Magnitude();
276  if (length != 0.0f)
277  {
278  // Divide is slow so calculate 1/length and multiply to save time
279  inv_length = 1.0f / length;
280 
281  x = x * inv_length;
282  y = y * inv_length;
283  z = z * inv_length;
284  }
285  }
286 
287  /** Returns the magnitude of the vector
288  * \return The resulting scalar
289  */
290  inline float Magnitude() const
291  { return float( sqrt( ((x)*(x)) + ((y)*(y)) + ((z)*(z))) ); }
292 
293  /** Returns the magnitude of the vector squared
294  * \return The resulting scalar
295  */
296  inline float MagnitudeSquared() const
297  { return x*x + y*y + z*z; }
298 
299  /** Returns the vector cross-product of this vector with the argument vector
300  * HS Algebra review: vector cross-product is the vector that is
301  * perpendicular to the two given vectors.
302  * \param w Second vector
303  * \return The resulting cross-product (vector)
304  */
305  inline VertexNoColor CrossProduct(const VertexNoColor &w) const
306  { return VertexNoColor((y * w.z) - (z * w.y),
307  (z * w.x) - (x * w.z),
308  (x * w.y) - (y * w.x));
309  }
310 
311  /** Returns the vector dot-product of this vector with the argument vector
312  * \param w Second vector
313  * \return The resulting dot-product (scalar)
314  */
315  inline float DotProduct(const VertexNoColor &w) const
316  { return ((x * w.x) + (y * w.y) + (z * w.z)); }
317 
318  /** Returns the angle (in radians) between this vector and the argument vect.
319  * \param arg Second vector
320  * \return The resulting angle (in radians)
321  */
322  DISTI_EXPORT float AngleToVector(const VertexNoColor &arg) const;
323 
324  /** Returns true if this vertex is in the given triangle specified by abc
325  * \param a First triangle vertex
326  * \param b Second triangle vertex
327  * \param c Third triangle vertex
328  * \return true if this point is inside the triangle, false otherwise
329  */
330  inline bool PointInTriangle(const VertexNoColor &a,const VertexNoColor &b,const VertexNoColor &c) const
331  {
332  float fAB,fBC,fCA;
333 
334  fAB = (y-a.y)*(b.x-a.x) - (x-a.x)*(b.y-a.y);
335  fBC = (y-b.y)*(c.x-b.x) - (x-b.x)*(c.y-b.y);
336  fCA = (y-c.y)*(a.x-c.x) - (x-c.x)*(a.y-c.y);
337 
338  return (((fAB*fBC) > 0) && ((fBC*fCA) > 0));
339  }
340 
341  /** Returns true if this vertex is within the radius specified by tolerance
342  * \param arg vertex to compare with
343  * \param tolerance the tolerance value
344  * \return true if this point within the tolerance
345  */
346  DISTI_EXPORT bool CloseTo(const VertexNoColor &arg, float tolerance = 0.0001f) const;
347 
348  /** Returns the distance of this point from the line defined by start and direction
349  * \param start Starting point of the line
350  * \param direction Normalized direction vector for the line
351  */
352  DISTI_EXPORT float DistanceFromLine(const VertexNoColor &start, const VertexNoColor &direction) const;
353 
354  /** Returns the projection of this point onto the line defined by origin and direction
355  * \param origin Starting point of the line
356  * \param direction Normalized direction vector for the line
357  */
358  DISTI_EXPORT VertexNoColor ProjectPointToLine(const VertexNoColor &origin, const VertexNoColor &direction) const;
359 };
360 // Stream operators
361 GLS_EXPORT std::istream& operator>>(std::istream& instr, Vector& vert) ;
362 GLS_EXPORT std::ostream& operator<<(std::ostream& outstr, const Vector& vert);
363 
364 /** A 3D coordinate in space with an RGBA color value */
365 class Vertex : public VertexNoColor
366 {
367 public:
368 
369  glsColor color;
370 
371  /** Simple constructor. Ensures all values are initialized */
373  {
374  color.RGBA(DEF_FILL_RCOLOR,DEF_FILL_GCOLOR,DEF_FILL_BCOLOR,DEF_FILL_ALPHA);
375  }
376 
377  /** Just add the default color constructor */
378  Vertex(const VertexNoColor& noColor) : VertexNoColor(noColor)
379  {
380  color.RGBA(DEF_FILL_RCOLOR,DEF_FILL_GCOLOR,DEF_FILL_BCOLOR,DEF_FILL_ALPHA);
381  }
382 
383  /** Just add the color constructor */
384  Vertex(const VertexNoColor& noColor, const glsColor& _color) : VertexNoColor(noColor),
385  color(_color)
386  {
387  }
388 
389  /** Position only constructor. Color values are set to defaults
390  \param _x The X value of the vertex, in logical units
391  \param _y The Y value of the vertex, in logical units
392  \param _z The Z value of the vertex, in logical units */
393  Vertex(float _x,float _y,float _z) : VertexNoColor( _x, _y, _z)
394  {
395  color.RGBA(DEF_FILL_RCOLOR,DEF_FILL_GCOLOR,DEF_FILL_BCOLOR,DEF_FILL_ALPHA);
396  }
397 
398  /** Position only constructor. Color values are set to defaults
399  \param _x The X value of the vertex, in logical units
400  \param _y The Y value of the vertex, in logical units
401  \param _z The Z value of the vertex, in logical units
402  \param _r The R value of the color of the vertex 0-255
403  \param _g The G value of the color of the vertex 0-255
404  \param _b The B value of the color of the vertex 0-255
405  \param _a The A value of the color of the vertex 0-255
406  */
407  Vertex(float _x,float _y,float _z,
408  unsigned char _r, unsigned char _g, unsigned char _b, unsigned char _a) :
409  VertexNoColor(_x, _y, _z)
410  {
411  color.RGBA(_r,_g,_b,_a);
412  }
413 
414  /** Position only constructor. Color values are set to defaults
415  \param _x The X value of the vertex, in logical units
416  \param _y The Y value of the vertex, in logical units
417  \param _z The Z value of the vertex, in logical units
418  \param _color The value of the color of the vertex
419  */
420  Vertex(float _x,float _y,float _z, const glsColor& _color) :
421  VertexNoColor( _x, _y, _z )
422  {
423  color = _color;
424  }
425 
426  /** Compute the result of adding this point to another one, in 3D
427  \param arg The vertex to add to this one
428  \return A new vertex V2 where V2 = this + v */
429  inline Vertex operator + (const VertexNoColor &arg) const
430  { return Vertex(x + arg.x,y + arg.y,z + arg.z, color); }
431 
432  /** Compute the result of multiplying this point by a scalar
433  \param s The Scalar to multiply by
434  \return A new vertex V2 where V2 = this * s */
435  inline Vertex operator * (const float s) const
436  { return Vertex(x*s,y*s,z*s, color); }
437 
438  /** Rotate this point in 2D around the z axis
439  \param angle The angle to rotate around, in degrees.
440  \return The rotated vertex */
441  DISTI_EXPORT Vertex Rotate(const float angle) const;
442 
443  /** Rotate this point around a different point in 2D around the z axis
444  \param orig The rotation origin to rotate around.
445  \param angle The angle to rotate around, in degrees.
446  \return The rotated vertex */
447  DISTI_EXPORT Vertex Rotate(const VertexNoColor &orig,const float angle) const;
448 
449  /** Rotate this point around a different point in 2D around the z axis
450  \param orig The rotation origin to rotate around.
451  \param angle The angle to rotate around, in degrees.
452  \param axis The axis to rotate 180 degrees around. x = 1, y = 2, z = 3.
453  \return The rotated vertex */
454  DISTI_EXPORT Vertex Rotate(const VertexNoColor &orig,const float angle,const int axis) const;
455 
456  /** Rotate this vertex by angle theta around an arbitrary axis r
457  Return the rotated point.
458  Positive angles are anticlockwise looking down the axis
459  towards the origin. */
460  DISTI_EXPORT Vertex Rotate(const VertexNoColor &orig, const float theta, const Vector &r) const;
461 
462  /** Compute the result of subtracting this point from another one, in 3D
463  \param arg The vertex to subtract from this one
464  \return A new vertex V2 where V2 = this - v */
465  inline Vertex operator - (const VertexNoColor &arg) const
466  { return Vertex(x - arg.x,y - arg.y,z - arg.z, color); }
467 
468  /** Negation operator */
469  inline Vertex operator - () const
470  { return Vertex(-x,-y,-z,color); }
471 
472  /** Computes the result of muliplying this point to another one.
473  \param arg vertex to multiple with
474  \return resulting vertex
475  */
476  inline Vertex operator * (const VertexNoColor &arg) const
477  {
478  return Vertex(x * arg.x,y * arg.y,z * arg.z, color);
479  }
480 
481  /** Returns the vector cross-product of this vector with the argument vector
482  * HS Algebra review: vector cross-product is the vector that is
483  * perpendicular to the two given vectors.
484  * \param w Second vector
485  * \return The resulting cross-product (vector)
486  */
487  inline Vertex CrossProduct(const VertexNoColor &w) const
488  { return Vertex(VertexNoColor::CrossProduct(w), color); }
489 };
490 
491 /**
492  The PlaneClass class: Implements a 3D plane
493 */
495 {
496  public:
497 
498  float a,b,c,d; /** Coefficients to describe a 3D plane: aX + bY + cZ + d = 0 */
499 
500  PlaneClass(void) { a = 0.0f; b = 0.0f; c = 0.0f; d = 0.0f; }
501 
502  PlaneClass(float A,float B,float C,float D) { a = A; b = B; c = C; d = D; }
503 };
504 
505 // Stream operators
506 DISTI_EXPORT std::istream& operator>>(std::istream& instr, Vertex& vert) ;
507 DISTI_EXPORT std::ostream& operator<<(std::ostream& outstr, const Vertex& vert);
508 
509 /** Computes whether or not a vector intersects a plane.
510  * \param point Returned parameter, contains intersection point on success
511  * \param lineVector Direction of the vector
512  * \param linePoint Origin point of the vector
513  * \param planeNormal Surface normal of the plane
514  * \param planePoint A point on the plane
515  * \return Non-zero if the vector intersects the plane
516  */
517 DISTI_EXPORT int IntersectionVectorAndPlane(VertexNoColor &point, const Vector &lineVector, const VertexNoColor &linePoint, const Vector &planeNormal, const Vector &planePoint);
518 
519 
520 /** Finds the point that (1) lies along the plane passing through p3
521  * and perpendicular to the vector p1-p2 and (2) lies along the line defined by
522  * p1 and p2
523  *
524  * Method: We have 3 unknowns (x,y,z) and 3 equations:
525  * The first known equation is the equation of the plane where
526  * vA is the vector p2 - p1
527  * eq 1: (x - p3.x)vA.x + (y - p3.y)vA.y + (z - p3.z)vA.z = 0
528  * The second and third equations are the projection form of the
529  * line defined by the points p1 and p2.
530  * eq 2: (x - p1.x) / (p2.x - p1.x) = (y - p1.y) / (p2.y - p1.y)
531  * eq 3: (x - p1.x) / (p2.x - p1.x) = (z - p1.z) / (p2.z - p1.z)
532  *
533  * \param p1 First point in the vector
534  * \param p2 Second point in the vector
535  * \param p3 A point in the plane p1,p2,p3
536  * \return The point of intersection
537  */
538 DISTI_EXPORT VertexNoColor ProjectedIntersectingPoint(const VertexNoColor& p1,const VertexNoColor& p2,const VertexNoColor& p3);
539 
540 /** Determines if a line intersects a triangle, and optionally where.
541  * \param origin The origin of the line to test
542  * \param direction The direction vector of the line
543  * \param v0 The first triangle point
544  * \param v1 The second triangle point
545  * \param v2 The third triangle point
546  * \param collisionPoint Returns where the triangle was hit (only set if the triangle was actually hit)
547  * \return True if the triangle is hit
548  * \note This function does what TriangleHit() and DoesLineIntersectTriangle() used to do, namely checking the intersection of a line with a triangle.
549  * Most users should use RayHitsTriangle() instead because using a line may return a collision in the opposite direction to the direction vector,
550  * which could result in a pick behind the viewer, for instance.
551  */
552 DISTI_EXPORT bool LineHitsTriangle(const Vector &origin,const Vector &direction,const Vector &v0,const Vector &v1,const Vector &v2,Vector *collisionPoint = 0);
553 
554 /** Determines if a ray intersects a triangle, and optionally where.
555  * \param origin The origin of the ray to test
556  * \param direction The direction vector of the ray
557  * \param v0 The first triangle point
558  * \param v1 The second triangle point
559  * \param v2 The third triangle point
560  * \param collisionPoint Returns where the triangle was hit (only set if the triangle was actually hit)
561  * \return True if the triangle is hit
562  * \note See note on LineHitsTriangle().
563  */
564 DISTI_EXPORT bool RayHitsTriangle(const Vector &origin,const Vector &direction,const Vector &v0,const Vector &v1,const Vector &v2,Vector *collisionPoint = 0);
565 
566 /** Find the point at which a line intersects a plane. Helper/preparer function for
567  * IntersectionVectorAndPlane.
568  * /param point Origin of the line
569  * /param vert1 First point defining the plane
570  * /param vert2 Second point defining the plane
571  * /param vert3 Third point defining the plane
572  * /param collisionPoint This will be set to the intersection point
573  * /param directionVector Vector to which the line is parallel
574  */
575 DISTI_EXPORT void FindCollision(const Vector &origin,const Vector &vert1, const Vector &vert2,const Vector &vert3, VertexNoColor *collisionPoint, const Vector &directionVector);
576 
577 /** Computes the Normal vector for the plane formed from the three given points.
578  * \param p1 First point
579  * \param p2 Second point
580  * \param p3 Third point
581  * \return The "normal" vector to the plane formed by p2,p2,p3
582  */
583 DISTI_EXPORT VertexNoColor Normal(const VertexNoColor& p1, const VertexNoColor& p2, const VertexNoColor& p3);
584 
585 } // namespace disti
586 
587 #endif
588 
The DistiUnhideGlobalsDummyClass class.
Vertex operator+(const VertexNoColor &arg) const
Definition: vertex.h:429
Vertex(const VertexNoColor &noColor)
Definition: vertex.h:378
Definition: vertex.h:494
Definition: vertex.h:365
VertexNoColor(float _x, float _y, float _z)
Definition: vertex.h:101
RotationAxis
Definition: vertex.h:73
Vertex(float _x, float _y, float _z, unsigned char _r, unsigned char _g, unsigned char _b, unsigned char _a)
Definition: vertex.h:407
VertexNoColor operator/(const float s) const
Definition: vertex.h:191
float MagnitudeSquared() const
Definition: vertex.h:296
Vertex()
Definition: vertex.h:372
VertexNoColor operator+(const VertexNoColor &arg) const
Definition: vertex.h:168
VertexNoColor ProjectedIntersectingPoint(const VertexNoColor &p1, const VertexNoColor &p2, const VertexNoColor &p3)
void Normalize(void)
Definition: vertex.h:271
Vertex(const VertexNoColor &noColor, const glsColor &_color)
Definition: vertex.h:384
float DotProduct(const VertexNoColor &w) const
Definition: vertex.h:315
bool CloseTo(const VertexNoColor &arg, float tolerance=0.0001f) const
bool LineHitsTriangle(const Vector &origin, const Vector &direction, const Vector &v0, const Vector &v1, const Vector &v2, Vector *collisionPoint=0)
Vertex(float _x, float _y, float _z)
Definition: vertex.h:393
The Color class: Implements a 4 component RGBA color.
A file for all GL Studio files to include.
VertexNoColor()
Definition: vertex.h:91
bool PointInTriangle(const VertexNoColor &a, const VertexNoColor &b, const VertexNoColor &c) const
Definition: vertex.h:330
void FindCollision(const Vector &origin, const Vector &vert1, const Vector &vert2, const Vector &vert3, VertexNoColor *collisionPoint, const Vector &directionVector)
VertexNoColor & operator/=(const float s)
Definition: vertex.h:197
VertexNoColor & operator+=(const VertexNoColor &arg)
Definition: vertex.h:204
VertexNoColor operator-() const
Definition: vertex.h:172
Vertex CrossProduct(const VertexNoColor &w) const
Definition: vertex.h:487
Definition: vertex.h:75
bool operator==(const VertexNoColor &arg) const
Definition: vertex.h:225
VertexNoColor operator*(const float s) const
Definition: vertex.h:178
float Distance2Squared(const VertexNoColor &v) const
Definition: vertex.h:156
Vertex(float _x, float _y, float _z, const glsColor &_color)
Definition: vertex.h:420
VertexNoColor Vector
Definition: gls_font_base.h:68
GL Studio Enumerations and constants.
Vertex Rotate(const float angle) const
VertexNoColor CrossProduct(const VertexNoColor &w) const
Definition: vertex.h:305
Vertex operator-() const
Definition: vertex.h:469
PlaneClass(void)
Definition: vertex.h:500
int IntersectionVectorAndPlane(VertexNoColor &point, const Vector &lineVector, const VertexNoColor &linePoint, const Vector &planeNormal, const Vector &planePoint)
VertexNoColor Rotate(const float angle) const
float Distance2(const VertexNoColor &v) const
Definition: vertex.h:162
Definition: gls_color.h:54
void RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: gls_color.h:164
VertexNoColor Normal(const VertexNoColor &p1, const VertexNoColor &p2, const VertexNoColor &p3)
float DistanceFromLine(const VertexNoColor &start, const VertexNoColor &direction) const
Vertex operator*(const float s) const
Definition: vertex.h:435
Definition: vertex.h:84
float Magnitude() const
Definition: vertex.h:290
float Distance3Squared(const VertexNoColor &v) const
Definition: vertex.h:111
VertexNoColor & operator*=(const float s)
Definition: vertex.h:184
Definition: vertex.h:77
bool operator!=(const VertexNoColor &arg) const
Definition: vertex.h:232
float Distance3(const VertexNoColor &v) const
Definition: vertex.h:149
float AngleToVector(const VertexNoColor &arg) const
Definition: vertex.h:76
VertexNoColor ProjectPointToLine(const VertexNoColor &origin, const VertexNoColor &direction) const
float DistanceFromLineSquared(const float startx, const float starty, const float startz, const VertexNoColor &direction) const
Definition: vertex.h:121
Definition: bmpimage.h:46
VertexNoColor & operator-=(const VertexNoColor &arg)
Definition: vertex.h:217
bool RayHitsTriangle(const Vector &origin, const Vector &direction, const Vector &v0, const Vector &v1, const Vector &v2, Vector *collisionPoint=0)