liba
0.1.15
An algorithm library based on C/C++
Toggle main menu visibility
Loading...
Searching...
No Matches
plane.h
Go to the documentation of this file.
1
5
6
#ifndef LIBA_PLANE_H
7
#define LIBA_PLANE_H
8
9
#include "
a.h
"
10
#include "
line3.h
"
11
17
19
#define a_plane_c(x) a_cast_s(a_plane, x)
20
#define a_plane_(_, x) a_cast_s(a_plane _, x)
21
22
typedef
struct
a_plane
a_plane
;
23
24
#if defined(__cplusplus)
25
namespace
a
26
{
27
typedef
struct
a_plane
plane;
28
}
/* namespace a */
29
extern
"C"
{
30
#endif
/* __cplusplus */
31
#if !defined A_HAVE_INLINE || defined(LIBA_PLANE_C)
33
#undef A_INTERN
34
#define A_INTERN A_PUBLIC extern
36
#endif
/* A_HAVE_INLINE */
37
38
A_INTERN
a_point3
const
*a_plane_org(
a_plane
const
*ctx);
39
A_INTERN
a_vector3
const
*a_plane_dir(
a_plane
const
*ctx);
40
A_INTERN
a_vector3
const
*a_plane_u(
a_plane
const
*ctx);
41
A_INTERN
a_vector3
const
*a_plane_v(
a_plane
const
*ctx);
42
A_INTERN
void
a_plane_set_org(
a_plane
*ctx,
a_real
x,
a_real
y,
a_real
z);
43
44
A_EXTERN
int
a_plane_set_dir(
a_plane
*ctx,
a_real
x,
a_real
y,
a_real
z);
45
A_EXPORT
int
a_plane_set_uv(
a_plane
*ctx,
a_vector3
const
*u,
a_vector3
const
*v);
46
A_EXPORT
int
a_plane_set_u(
a_plane
*ctx,
a_vector3
const
*n,
a_vector3
const
*u);
47
A_EXPORT
int
a_plane_set_v(
a_plane
*ctx,
a_vector3
const
*n,
a_vector3
const
*v);
48
A_EXTERN
int
a_plane_set(
a_plane
*ctx,
a_point3
const
*p,
a_vector3
const
*n);
49
A_EXTERN
int
a_plane_seto(
a_plane
*ctx,
a_point3
const
*p1,
a_point3
const
*p2,
a_point3
const
*p3);
50
A_EXTERN
int
a_plane_set3(
a_plane
*ctx,
a_point3
const
*o,
a_point3
const
*u,
a_point3
const
*v);
51
A_EXTERN
int
a_plane_set4(
a_plane
*ctx,
a_real
a,
a_real
b,
a_real
c,
a_real
d);
52
A_INTERN
void
a_plane_eval(
a_plane
const
*ctx,
a_real
u,
a_real
v,
a_point3
*res);
53
A_EXTERN
void
a_plane_parm(
a_plane
const
*ctx,
a_point3
const
*p,
a_real
*u,
a_real
*v);
54
A_EXTERN
a_real
a_plane_proj(
a_plane
const
*ctx,
a_point3
const
*p,
a_point3
*res);
55
56
A_EXTERN
a_real
a_plane_sdist(
a_plane
const
*ctx,
a_point3
const
*rhs);
57
A_EXTERN
a_real
a_plane_dist(
a_plane
const
*ctx,
a_point3
const
*rhs);
58
59
A_EXTERN
int
a_plane_int0(
a_plane
const
*ctx,
a_point3
const
*rhs,
a_real
*u,
a_real
*v);
60
A_EXTERN
int
a_plane_int1(
a_plane
const
*ctx,
a_line3
const
*rhs,
a_real
min,
a_real
max,
a_real
*w);
61
A_EXTERN
int
a_plane_int2(
a_plane
const
*ctx,
a_plane
const
*rhs,
a_line3
*res);
62
63
A_EXTERN
void
a_plane_rot2d(
a_plane
*ctx,
a_real
angle);
64
65
#if !defined A_HAVE_INLINE || defined(LIBA_PLANE_C)
67
#undef A_INTERN
68
#define A_INTERN static A_INLINE
70
#endif
/* A_HAVE_INLINE */
71
#if defined(__cplusplus)
72
}
/* extern "C" */
73
#endif
/* __cplusplus */
74
78
struct
a_plane
79
{
80
a_point3
org;
81
a_vector3
dir_, u_, v_;
82
#if defined(__cplusplus)
83
A_INLINE
void
set_org(
a_real
x,
a_real
y,
a_real
z)
84
{
85
a_plane_set_org(
this
, x, y, z);
86
}
87
A_INLINE
a_vector3
const
&dir()
const
{
return
dir_; }
88
A_INLINE
int
set_dir(
a_real
x,
a_real
y,
a_real
z)
89
{
90
return
a_plane_set_dir(
this
, x, y, z);
91
}
92
A_INLINE
int
set_uv(
a_vector3
const
&u,
a_vector3
const
&v)
93
{
94
return
a_plane_set_uv(
this
, &u, &v);
95
}
96
A_INLINE
int
set_u(
a_vector3
const
&n,
a_vector3
const
&u)
97
{
98
return
a_plane_set_u(
this
, &n, &u);
99
}
100
A_INLINE
int
set_v(
a_vector3
const
&n,
a_vector3
const
&v)
101
{
102
return
a_plane_set_v(
this
, &n, &v);
103
}
104
A_INLINE
a_vector3
const
&u()
const
{
return
u_; }
105
A_INLINE
a_vector3
const
&v()
const
{
return
v_; }
106
A_INLINE
int
set(
a_point3
const
&p,
a_vector3
const
&n)
107
{
108
return
a_plane_set(
this
, &p, &n);
109
}
110
A_INLINE
int
seto(
a_point3
const
&p1,
a_point3
const
&p2,
a_point3
const
&p3)
111
{
112
return
a_plane_seto(
this
, &p1, &p2, &p3);
113
}
114
A_INLINE
int
set(
a_point3
const
&o,
a_point3
const
&u,
a_point3
const
&v)
115
{
116
return
a_plane_set3(
this
, &o, &u, &v);
117
}
118
A_INLINE
int
set(
a_real
a,
a_real
b,
a_real
c,
a_real
d)
119
{
120
return
a_plane_set4(
this
, a, b, c, d);
121
}
122
A_INLINE
void
eval(
a_real
u,
a_real
v,
a_point3
&res)
const
123
{
124
a_plane_eval(
this
, u, v, &res);
125
}
126
A_INLINE
void
parm(
a_point3
const
&p,
a_real
&u,
a_real
&v)
const
127
{
128
a_plane_parm(
this
, &p, &u, &v);
129
}
130
A_INLINE
a_real
proj(
a_point3
const
&p,
a_point3
&res)
const
131
{
132
return
a_plane_proj(
this
, &p, &res);
133
}
134
A_INLINE
a_real
sdist(
a_point3
const
&rhs)
const
135
{
136
return
a_plane_sdist(
this
, &rhs);
137
}
138
A_INLINE
a_real
dist(
a_point3
const
&rhs)
const
139
{
140
return
a_plane_dist(
this
, &rhs);
141
}
142
A_INLINE
int
int0(
a_point3
const
&rhs,
a_real
&u,
a_real
&v)
const
143
{
144
return
a_plane_int0(
this
, &rhs, &u, &v);
145
}
146
A_INLINE
int
int1(
a_line3
const
&rhs,
a_real
min,
a_real
max,
a_real
&w)
const
147
{
148
return
a_plane_int1(
this
, &rhs, min, max, &w);
149
}
150
A_INLINE
int
int2(
a_plane
const
&rhs,
a_line3
&res)
const
151
{
152
return
a_plane_int2(
this
, &rhs, &res);
153
}
154
A_INLINE
void
rot2d(
a_real
angle)
155
{
156
a_plane_rot2d(
this
, angle);
157
}
158
#endif
/* __cplusplus */
159
};
160
161
#if defined(LIBA_PLANE_C)
163
#undef A_INTERN
164
#define A_INTERN A_INLINE
166
#endif
/* LIBA_PLANE_C */
167
#if defined(A_HAVE_INLINE) || defined(LIBA_PLANE_C)
168
169
A_INTERN
a_point3
const
*a_plane_org(
a_plane
const
*ctx)
170
{
171
return
&ctx->org;
172
}
173
A_INTERN
a_vector3
const
*a_plane_dir(
a_plane
const
*ctx)
174
{
175
return
&ctx->dir_;
176
}
177
A_INTERN
a_vector3
const
*a_plane_u(
a_plane
const
*ctx)
178
{
179
return
&ctx->u_;
180
}
181
A_INTERN
a_vector3
const
*a_plane_v(
a_plane
const
*ctx)
182
{
183
return
&ctx->v_;
184
}
185
A_INTERN
void
a_plane_set_org(
a_plane
*ctx,
a_real
x,
a_real
y,
a_real
z)
186
{
187
ctx->org.x = x;
188
ctx->org.y = y;
189
ctx->org.z = z;
190
}
191
192
A_INTERN
void
a_plane_eval(
a_plane
const
*ctx,
a_real
u,
a_real
v,
a_point3
*res)
193
{
194
a_point3
const
*
const
o = &ctx->org;
195
a_vector3
const
*
const
a = &ctx->u_;
196
a_vector3
const
*
const
b = &ctx->v_;
197
res->x = o->x + a->x * u + b->x * v;
198
res->y = o->y + a->y * u + b->y * v;
199
res->z = o->z + a->z * u + b->z * v;
200
}
201
202
#endif
/* A_HAVE_INLINE */
203
#if defined(LIBA_PLANE_C)
205
#undef A_INTERN
206
#define A_INTERN static A_INLINE
208
#endif
/* LIBA_PLANE_C */
209
211
212
#endif
/* a/plane.h */
a.h
algorithm library
a_real
double a_real
compiler built-in floating-point number type
Definition
a.h:1012
line3.h
three-dimensional line
a_line3
instance structure for three-dimensional line defined by an origin, a direction vector,...
Definition
line3.h:312
a_plane
instance structure for three-dimensional plane
Definition
plane.h:79
a_point3
instance structure for three-dimensional point
Definition
point3.h:350
a_vector3
instance structure for three-dimensional vector
Definition
vector3.h:415
plane.h
Generated by
1.17.0