KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ray.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015-2017 Mario Luzeiro <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef RAY_H
22#define RAY_H
23
25
26
56
57
58struct RAY
59{
61 unsigned int rayID;
62
65
67
68 float ibyj, jbyi, kbyj, jbyk, ibyk, kbyi; // slope
69 float c_xy, c_xz, c_yx, c_yz, c_zx, c_zy;
70
71 unsigned int m_dirIsNeg[3];
72
73 void Init( const SFVEC3F& o, const SFVEC3F& d );
74
75 bool IntersectSphere( const SFVEC3F &aCenter,
76 float aRadius,
77 float &aOutT0,
78 float &aOutT1 ) const;
79
80 SFVEC3F at( float t ) const { return m_Origin + m_Dir * t; }
81
82 SFVEC2F at2D( float t ) const
83 {
84 return SFVEC2F( m_Origin.x + m_Dir.x * t, m_Origin.y + m_Dir.y * t );
85 }
86};
87
88
89struct RAY2D
90{
94
95 RAY2D( const SFVEC2F& o, const SFVEC2F& d ) { m_Origin = o; m_Dir = d; m_InvDir = (1.0f / d); }
96
97 SFVEC2F at( float t ) const { return m_Origin + m_Dir * t; }
98};
99
100
102{
108 float m_Length;
110
111 RAYSEG2D( const SFVEC2F& s, const SFVEC2F& e );
112
113 bool IntersectSegment( const SFVEC2F &aStart,
114 const SFVEC2F &aEnd_minus_start,
115 float *aOutT ) const;
116
117 bool IntersectCircle( const SFVEC2F &aCenter,
118 float aRadius,
119 float *aOutT0,
120 float *aOutT1,
121 SFVEC2F *aOutNormalT0,
122 SFVEC2F *aOutNormalT1 ) const;
123
124 float DistanceToPointSquared( const SFVEC2F &aPoint ) const;
125
131 SFVEC2F atNormalized( float t ) const { return m_Start + m_End_minus_start * t; }
132
133 SFVEC2F at( float t ) const { return m_Start + m_Dir * t; }
134};
135
136
137bool IntersectSegment( const SFVEC2F &aStartA, const SFVEC2F &aEnd_minus_startA,
138 const SFVEC2F &aStartB, const SFVEC2F &aEnd_minus_startB );
139
140/*
141#if(GLM_ARCH != GLM_ARCH_PURE)
142struct RAY4
143{
144 glm::simdVec4 m_orgX; ///< x coordinate of ray origin
145 glm::simdVec4 m_orgy; ///< y coordinate of ray origin
146 glm::simdVec4 m_orgz; ///< z coordinate of ray origin
147
148 glm::simdVec4 m_dirX; ///< x direction of ray
149 glm::simdVec4 m_diry; ///< y direction of ray
150 glm::simdVec4 m_dirz; ///< z direction of ray
151
152 glm::simdVec4 m_tnear; ///< Start of ray segment
153 glm::simdVec4 m_tfar; ///< End of ray segment
154};
155
156#endif
157*/
158
159
160#endif // RAY_H
RAY_CLASSIFICATION
Definition ray.h:28
bool IntersectSegment(const SFVEC2F &aStartA, const SFVEC2F &aEnd_minus_startA, const SFVEC2F &aStartB, const SFVEC2F &aEnd_minus_startB)
Definition ray.cpp:177
SFVEC2F m_Origin
Definition ray.h:91
SFVEC2F at(float t) const
Definition ray.h:97
SFVEC2F m_Dir
Definition ray.h:92
RAY2D(const SFVEC2F &o, const SFVEC2F &d)
Definition ray.h:95
SFVEC2F m_InvDir
Definition ray.h:93
bool IntersectCircle(const SFVEC2F &aCenter, float aRadius, float *aOutT0, float *aOutT1, SFVEC2F *aOutNormalT0, SFVEC2F *aOutNormalT1) const
Definition ray.cpp:315
bool IntersectSegment(const SFVEC2F &aStart, const SFVEC2F &aEnd_minus_start, float *aOutT) const
Definition ray.cpp:258
float m_DOT_End_minus_start
dot( m_End_minus_start, m_End_minus_start)
Definition ray.h:109
float DistanceToPointSquared(const SFVEC2F &aPoint) const
Definition ray.cpp:290
float m_Length
Definition ray.h:108
SFVEC2F m_End_minus_start
Definition ray.h:105
SFVEC2F m_Dir
Definition ray.h:106
SFVEC2F m_InvDir
Definition ray.h:107
SFVEC2F atNormalized(float t) const
Return the position at t.
Definition ray.h:131
SFVEC2F at(float t) const
Definition ray.h:133
SFVEC2F m_Start
Definition ray.h:103
SFVEC2F m_End
Definition ray.h:104
RAYSEG2D(const SFVEC2F &s, const SFVEC2F &e)
Definition ray.cpp:239
Definition ray.h:59
float ibyj
Definition ray.h:68
SFVEC3F m_Dir
Definition ray.h:63
void Init(const SFVEC3F &o, const SFVEC3F &d)
Definition ray.cpp:31
unsigned int m_dirIsNeg[3]
Definition ray.h:71
float c_zx
Definition ray.h:69
float jbyk
Definition ray.h:68
RAY_CLASSIFICATION m_Classification
Definition ray.h:64
float jbyi
Definition ray.h:68
float c_xz
Definition ray.h:69
float c_xy
Definition ray.h:69
float c_yz
Definition ray.h:69
bool IntersectSphere(const SFVEC3F &aCenter, float aRadius, float &aOutT0, float &aOutT1) const
Definition ray.cpp:207
float kbyi
Definition ray.h:68
SFVEC3F m_InvDir
Definition ray.h:66
SFVEC3F m_Origin
Definition ray.h:60
float ibyk
Definition ray.h:68
float c_yx
Definition ray.h:69
SFVEC3F at(float t) const
Definition ray.h:80
float c_zy
Definition ray.h:69
unsigned int rayID
unique ray ID - not used - dummy
Definition ray.h:61
float kbyj
Definition ray.h:68
SFVEC2F at2D(float t) const
Definition ray.h:82
glm::vec2 SFVEC2F
Definition xv3d_types.h:38
glm::vec3 SFVEC3F
Definition xv3d_types.h:40