liba 0.1.15
An algorithm library based on C/C++
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
22typedef struct a_plane a_plane;
23
24#if defined(__cplusplus)
25namespace a
26{
27typedef struct a_plane plane;
28} /* namespace a */
29extern "C" {
30#endif /* __cplusplus */
31#if !defined A_HAVE_INLINE || defined(LIBA_PLANE_C)
32#undef A_INTERN
33#define A_INTERN A_PUBLIC extern
34#endif /* A_HAVE_INLINE */
35
36A_INTERN a_point3 const *a_plane_org(a_plane const *ctx);
37A_INTERN a_vector3 const *a_plane_dir(a_plane const *ctx);
38A_INTERN a_vector3 const *a_plane_u(a_plane const *ctx);
39A_INTERN a_vector3 const *a_plane_v(a_plane const *ctx);
40A_INTERN void a_plane_set_org(a_plane *ctx, a_real x, a_real y, a_real z);
41
42A_EXTERN int a_plane_set_dir(a_plane *ctx, a_real x, a_real y, a_real z);
43A_EXPORT int a_plane_set_uv(a_plane *ctx, a_vector3 const *u, a_vector3 const *v);
44A_EXPORT int a_plane_set_u(a_plane *ctx, a_vector3 const *n, a_vector3 const *u);
45A_EXPORT int a_plane_set_v(a_plane *ctx, a_vector3 const *n, a_vector3 const *v);
46A_EXTERN int a_plane_set(a_plane *ctx, a_point3 const *p, a_vector3 const *n);
47A_EXTERN int a_plane_set3(a_plane *ctx, a_point3 const *p1, a_point3 const *p2, a_point3 const *p3);
48A_EXTERN int a_plane_set4(a_plane *ctx, a_real a, a_real b, a_real c, a_real d);
49A_EXTERN void a_plane_eval(a_plane const *ctx, a_real u, a_real v, a_point3 *res);
50A_EXTERN void a_plane_parm(a_plane const *ctx, a_point3 const *p, a_real *u, a_real *v);
51A_EXTERN a_real a_plane_proj(a_plane const *ctx, a_point3 const *p, a_point3 *res);
52
53A_EXTERN a_real a_plane_sdist(a_plane const *ctx, a_point3 const *rhs);
54A_EXTERN a_real a_plane_dist(a_plane const *ctx, a_point3 const *rhs);
55
56A_EXTERN int a_plane_int0(a_plane const *ctx, a_point3 const *rhs, a_real *u, a_real *v);
57A_EXTERN int a_plane_int1(a_plane const *ctx, a_line3 const *rhs, a_real min, a_real max, a_real *w);
58A_EXTERN int a_plane_int2(a_plane const *ctx, a_plane const *rhs, a_line3 *res);
59
60A_EXTERN void a_plane_rot2d(a_plane *ctx, a_real angle);
61
62#if !defined A_HAVE_INLINE || defined(LIBA_PLANE_C)
63#undef A_INTERN
64#define A_INTERN static A_INLINE
65#endif /* A_HAVE_INLINE */
66#if defined(__cplusplus)
67} /* extern "C" */
68#endif /* __cplusplus */
69
73struct a_plane
74{
75 a_point3 orig;
76 a_vector3 dir_, u_, v_;
77#if defined(__cplusplus)
78 A_INLINE a_point3 const &org() const { return orig; }
79 A_INLINE void set_org(a_real x, a_real y, a_real z)
80 {
81 a_plane_set_org(this, x, y, z);
82 }
83 A_INLINE a_vector3 const &dir() const { return dir_; }
84 A_INLINE int set_dir(a_real x, a_real y, a_real z)
85 {
86 return a_plane_set_dir(this, x, y, z);
87 }
88 A_INLINE int set_uv(a_vector3 const &u, a_vector3 const &v)
89 {
90 return a_plane_set_uv(this, &u, &v);
91 }
92 A_INLINE int set_u(a_vector3 const &n, a_vector3 const &u)
93 {
94 return a_plane_set_u(this, &n, &u);
95 }
96 A_INLINE int set_v(a_vector3 const &n, a_vector3 const &v)
97 {
98 return a_plane_set_v(this, &n, &v);
99 }
100 A_INLINE a_vector3 const &u() const { return u_; }
101 A_INLINE a_vector3 const &v() const { return v_; }
102 A_INLINE int set(a_point3 const &p, a_vector3 const &n)
103 {
104 return a_plane_set(this, &p, &n);
105 }
106 A_INLINE int set(a_point3 const &p1, a_point3 const &p2, a_point3 const &p3)
107 {
108 return a_plane_set3(this, &p1, &p2, &p3);
109 }
110 A_INLINE void eval(a_real u, a_real v, a_point3 &res) const
111 {
112 a_plane_eval(this, u, v, &res);
113 }
114 A_INLINE void parm(a_point3 const &p, a_real &u, a_real &v) const
115 {
116 a_plane_parm(this, &p, &u, &v);
117 }
118 A_INLINE a_real proj(a_point3 const &p, a_point3 &res) const
119 {
120 return a_plane_proj(this, &p, &res);
121 }
122 A_INLINE a_real sdist(a_point3 const &rhs) const
123 {
124 return a_plane_sdist(this, &rhs);
125 }
126 A_INLINE a_real dist(a_point3 const &rhs) const
127 {
128 return a_plane_dist(this, &rhs);
129 }
130 A_INLINE int int0(a_point3 const &rhs, a_real &u, a_real &v) const
131 {
132 return a_plane_int0(this, &rhs, &u, &v);
133 }
134 A_INLINE int int1(a_line3 const &rhs, a_real min, a_real max, a_real &w) const
135 {
136 return a_plane_int1(this, &rhs, min, max, &w);
137 }
138 A_INLINE int int2(a_plane const &rhs, a_line3 &res) const
139 {
140 return a_plane_int2(this, &rhs, &res);
141 }
142 A_INLINE void rot2d(a_real angle)
143 {
144 a_plane_rot2d(this, angle);
145 }
146#endif /* __cplusplus */
147};
148
149#if defined(LIBA_PLANE_C)
150#undef A_INTERN
151#define A_INTERN A_INLINE
152#endif /* LIBA_PLANE_C */
153#if defined(A_HAVE_INLINE) || defined(LIBA_PLANE_C)
154
155A_INTERN a_point3 const *a_plane_org(a_plane const *ctx)
156{
157 return &ctx->orig;
158}
159A_INTERN a_vector3 const *a_plane_dir(a_plane const *ctx)
160{
161 return &ctx->dir_;
162}
163A_INTERN a_vector3 const *a_plane_u(a_plane const *ctx)
164{
165 return &ctx->u_;
166}
167A_INTERN a_vector3 const *a_plane_v(a_plane const *ctx)
168{
169 return &ctx->v_;
170}
171A_INTERN void a_plane_set_org(a_plane *ctx, a_real x, a_real y, a_real z)
172{
173 ctx->orig.x = x;
174 ctx->orig.y = y;
175 ctx->orig.z = z;
176}
177
178#endif /* A_HAVE_INLINE */
179#if defined(LIBA_PLANE_C)
180#undef A_INTERN
181#define A_INTERN static A_INLINE
182#endif /* LIBA_PLANE_C */
183
185
186#endif /* a/plane.h */
algorithm library
double a_real
compiler built-in floating-point number type
Definition a.h:1012
three-dimensional line
instance structure for three-dimensional line
Definition line3.h:88
instance structure for three-dimensional plane
Definition plane.h:74
instance structure for three-dimensional point
Definition point3.h:77
instance structure for three-dimensional vector
Definition vector3.h:87