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)
33#undef A_INTERN
34#define A_INTERN A_PUBLIC extern
36#endif /* A_HAVE_INLINE */
37
38A_INTERN a_point3 const *a_plane_org(a_plane const *ctx);
39A_INTERN a_vector3 const *a_plane_dir(a_plane const *ctx);
40A_INTERN a_vector3 const *a_plane_u(a_plane const *ctx);
41A_INTERN a_vector3 const *a_plane_v(a_plane const *ctx);
42A_INTERN void a_plane_set_org(a_plane *ctx, a_real x, a_real y, a_real z);
43
44A_EXTERN int a_plane_set_dir(a_plane *ctx, a_real x, a_real y, a_real z);
45A_EXPORT int a_plane_set_uv(a_plane *ctx, a_vector3 const *u, a_vector3 const *v);
46A_EXPORT int a_plane_set_u(a_plane *ctx, a_vector3 const *n, a_vector3 const *u);
47A_EXPORT int a_plane_set_v(a_plane *ctx, a_vector3 const *n, a_vector3 const *v);
48A_EXTERN int a_plane_set(a_plane *ctx, a_point3 const *p, a_vector3 const *n);
49A_EXTERN int a_plane_set3(a_plane *ctx, a_point3 const *p1, a_point3 const *p2, a_point3 const *p3);
50A_EXTERN int a_plane_set4(a_plane *ctx, a_real a, a_real b, a_real c, a_real d);
51A_EXTERN void a_plane_eval(a_plane const *ctx, a_real u, a_real v, a_point3 *res);
52A_EXTERN void a_plane_parm(a_plane const *ctx, a_point3 const *p, a_real *u, a_real *v);
53A_EXTERN a_real a_plane_proj(a_plane const *ctx, a_point3 const *p, a_point3 *res);
54
55A_EXTERN a_real a_plane_sdist(a_plane const *ctx, a_point3 const *rhs);
56A_EXTERN a_real a_plane_dist(a_plane const *ctx, a_point3 const *rhs);
57
58A_EXTERN int a_plane_int0(a_plane const *ctx, a_point3 const *rhs, a_real *u, a_real *v);
59A_EXTERN int a_plane_int1(a_plane const *ctx, a_line3 const *rhs, a_real min, a_real max, a_real *w);
60A_EXTERN int a_plane_int2(a_plane const *ctx, a_plane const *rhs, a_line3 *res);
61
62A_EXTERN void a_plane_rot2d(a_plane *ctx, a_real angle);
63
64#if !defined A_HAVE_INLINE || defined(LIBA_PLANE_C)
66#undef A_INTERN
67#define A_INTERN static A_INLINE
69#endif /* A_HAVE_INLINE */
70#if defined(__cplusplus)
71} /* extern "C" */
72#endif /* __cplusplus */
73
77struct a_plane
78{
79 a_point3 orig;
80 a_vector3 dir_, u_, v_;
81#if defined(__cplusplus)
82 A_INLINE a_point3 const &org() const { return orig; }
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 set(a_point3 const &p1, a_point3 const &p2, a_point3 const &p3)
111 {
112 return a_plane_set3(this, &p1, &p2, &p3);
113 }
114 A_INLINE void eval(a_real u, a_real v, a_point3 &res) const
115 {
116 a_plane_eval(this, u, v, &res);
117 }
118 A_INLINE void parm(a_point3 const &p, a_real &u, a_real &v) const
119 {
120 a_plane_parm(this, &p, &u, &v);
121 }
122 A_INLINE a_real proj(a_point3 const &p, a_point3 &res) const
123 {
124 return a_plane_proj(this, &p, &res);
125 }
126 A_INLINE a_real sdist(a_point3 const &rhs) const
127 {
128 return a_plane_sdist(this, &rhs);
129 }
130 A_INLINE a_real dist(a_point3 const &rhs) const
131 {
132 return a_plane_dist(this, &rhs);
133 }
134 A_INLINE int int0(a_point3 const &rhs, a_real &u, a_real &v) const
135 {
136 return a_plane_int0(this, &rhs, &u, &v);
137 }
138 A_INLINE int int1(a_line3 const &rhs, a_real min, a_real max, a_real &w) const
139 {
140 return a_plane_int1(this, &rhs, min, max, &w);
141 }
142 A_INLINE int int2(a_plane const &rhs, a_line3 &res) const
143 {
144 return a_plane_int2(this, &rhs, &res);
145 }
146 A_INLINE void rot2d(a_real angle)
147 {
148 a_plane_rot2d(this, angle);
149 }
150#endif /* __cplusplus */
151};
152
153#if defined(LIBA_PLANE_C)
155#undef A_INTERN
156#define A_INTERN A_INLINE
158#endif /* LIBA_PLANE_C */
159#if defined(A_HAVE_INLINE) || defined(LIBA_PLANE_C)
160
161A_INTERN a_point3 const *a_plane_org(a_plane const *ctx)
162{
163 return &ctx->orig;
164}
165A_INTERN a_vector3 const *a_plane_dir(a_plane const *ctx)
166{
167 return &ctx->dir_;
168}
169A_INTERN a_vector3 const *a_plane_u(a_plane const *ctx)
170{
171 return &ctx->u_;
172}
173A_INTERN a_vector3 const *a_plane_v(a_plane const *ctx)
174{
175 return &ctx->v_;
176}
177A_INTERN void a_plane_set_org(a_plane *ctx, a_real x, a_real y, a_real z)
178{
179 ctx->orig.x = x;
180 ctx->orig.y = y;
181 ctx->orig.z = z;
182}
183
184#endif /* A_HAVE_INLINE */
185#if defined(LIBA_PLANE_C)
187#undef A_INTERN
188#define A_INTERN static A_INLINE
190#endif /* LIBA_PLANE_C */
191
193
194#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:90
instance structure for three-dimensional plane
Definition plane.h:78
instance structure for three-dimensional point
Definition point3.h:193
instance structure for three-dimensional vector
Definition vector3.h:387