23 mfunname(
"polyline::polyline( polyline &pl)");
27 mfunname(
"polyline::polyline(const polyline &pl)");
31 mfunname(
"polyline::polyline(const point* fpt, int fqpt)");
36 mfunname(
"polyline::polyline(const point& fpt1, const point& fpt2)");
44 mfunname(
"polyline& polyline::operator=(const polyline& fpl)");
51 pvecerror(
"void polyline::polyline_init(const point* fpt, int fqpt)");
72 for (
int n = 0; n <
qpt; ++n)
aref[n] = &
pt[n];
77 pvecerror(
"int polyline::check_point_in(point& fpt, vfloat prec)");
78 for (
int n = 0; n <
qpt; ++n) {
79 if (
apeq(
pt[n], fpt, prec))
return 1;
81 for (
int n = 0; n <
qsl; ++n) {
84 vec v2 = fpt -
pt[n + 1];
85 if (check_par(v1, v2, prec) == -1) {
95 int& qpl,
vfloat prec)
const {
96 pvecerror(
"void polyline::cross(const straight& fsl, ...)");
99 for (
int n = 0; n <
qsl; ++n) {
100 pc[qpc] =
sl[n].
cross(fsl, prec);
108 vec v1 = pc[qpc] -
pt[n];
112 vec v2 = pc[qpc] -
pt[n + 1];
115 }
else if (check_par(v1, v2, prec) == -1) {
122 if (qpc > 0 || qpl > 0)
return 1;
127 pvecerror(
"vfloat polyline::dist_two_inter(polyline& pl)");
134 if (type_of_cross == 2 || type_of_cross == 3)
return sldist;
148 pvecerror(
"vfloat polyline::distance(const point& fpt) const");
154 for (n = 0; n <
qsl; n++) {
156 vec v1 = cpt -
pt[n];
157 vec v2 = cpt -
pt[n + 1];
158 if (check_par(v1, v2, 0.01) ==
160 if (sldist < mx) mx = sldist;
162 if ((sldist = (fpt -
pt[n]).length()) < mx) mx = sldist;
163 if ((sldist = (fpt -
pt[n + 1]).length()) < mx) mx = sldist;
170 pvecerror(
"vfloat polyline::distance(const point& fpt) const");
176 for (n = 0; n <
qsl; n++) {
178 vec v1 = cpt -
pt[n];
179 vec v2 = cpt -
pt[n + 1];
180 if (check_par(v1, v2, 0.01) ==
187 if ((sldist = (fpt -
pt[n]).length()) < mx) {
191 if ((sldist = (fpt -
pt[n + 1]).length()) < mx) {
203 "int cross4pllines(const polyline pl[4], straight& sl, point ptc[4][2])");
206 for (n = 0; n < 4; n++) slpl[n] = pl[n].Gsl(0);
208 pt[0] = (pl[1].
Gpt(0).
v + pl[1].
Gpt(1).
v) * 0.5;
209 pt[1] = (pl[2].
Gpt(0).
v + pl[2].
Gpt(1).
v) * 0.5;
212 for (n = 0; n < 4; n++) {
213 sl.
distance(pl[n].Gsl(0), type_of_cross, ptc[n]);
215 if (pl[n].check_point_in(ptc[n][1], precision) == 0)
223 Ifile <<
"polyline:\n";
226 for (n = 0; n < p.
qpt; n++) file << p.
pt[n];
228 for (n = 0; n < p.
qsl; n++) file << p.
sl[n];
241 mfunname(
"polyline_pl::polyline_pl( polyline& pl)");
243 mcerr <<
"error in polyline_pl(polyline& pl): qsl=" <<
Gqsl();
251 mfunname(
"polyline_pl::polyline_pl(const polyline& pl");
253 mcerr <<
"error in polyline_pl(polyline& pl): qsl=" <<
Gqsl();
261 mfunname(
"polyline_pl& polyline_pl::operator=(const polyline_pl& fpl)");
269 Ifile <<
"polyline_pl:\n";
273 file << static_cast<const polyline&>(p);
282 pvecerror(
"polygon::polygon(const straight* fsl, int fqsl)");
289 for (n = 0; n < fqsl - 1; n++)
290 for (m = n + 1; m < fqsl; m++) {
291 if (fsl[n].Gpiv() == fsl[m].Gpiv())
292 if (check_par(fsl[n].Gdir(), fsl[m].Gdir(), 0) !=
295 mcerr <<
"error in polyline_init(straight* fsl, int fqsl):\n"
296 <<
"Parallel lines with the same pivot cannot form polygin\n";
297 for (
int k = 0; k < fqsl; k++)
298 mcout <<
"n=" << k <<
" fsl[n]=" << fsl[k];
304 for (n = 1; n < fqsl; n++) {
305 ptl[n] = fsl[n - 1].
cross(fsl[n], prec);
307 mcerr <<
"error in polygon::polygon(straight* fsl, int fqsl):\n"
308 <<
" straight lines are not crossed properly\n"
309 <<
"fsl[n-1]=" << fsl[n - 1] <<
"fsl[n]=" << fsl[n]
314 ptl[0] = fsl[fqsl - 1].
cross(fsl[0], prec);
316 mcerr <<
"error in polygon::polygon(straight* fsl, int fqsl):\n"
317 <<
" straight lines are not crossed properly\n"
318 <<
"fsl[fqsl-1]=" << fsl[fqsl - 1] <<
"fsl[0]=" << fsl[0]
323 plane pnl =
plane(fsl[0].Gpiv(), fsl[0].Gdir() || fsl[1].Gdir());
331 mfunname(
"polygon& polygon::operator=(const polygon& fpl)");
340 pvecerror(
"int polygon::check_point_in(point& fpt)");
363 for (n = 0; n <
qpt - 1; n++) {
370 ang2 = 2 * M_PI - ang;
375 if (
fabs(totang) > 6.0)
return 3;
380 pvecerror(
"point polygon::cross(straight& fsl)");
396 "int polygon::range(const point& fpt, const vec& dir, vfloat& rng, "
405 const int i = check_par(dif, dir, prec);
415 Ifile <<
"polygon:\n";
419 file << static_cast<const polyline_pl&>(p);
435 "rectangle::rectangle(point fpiv, vec fdir[2], vfloat fdim[2], "
437 if (check_perp(fdir[0], fdir[1], prec) != 1) {
438 mcerr <<
"rectangle::rectangle(point fpiv, vec fdir[2], vfloat fdim[2]):\n"
439 <<
" error: sides are not perpendicular\n";
444 mcerr <<
"fdir[2](directions of sides):\n" << fdir[0] << fdir[1];
447 if (fdim[0] <= 0 || fdim[1] <= 0) {
448 mcerr <<
"rectangle::rectangle(point fpiv, vec fdir[2], vfloat fdim[2]):\n"
449 <<
" error: fdim[0] <=0 || fdim[1] <=0\n";
450 mcerr <<
"fdim (dimensions):" << fdim[0] <<
' ' << fdim[1] <<
'\n';
451 mcerr <<
"fdir[2](directions of sides):\n" << fdir[0] << fdir[1];
455 dir1 = unit_vec(fdir[0]);
456 dir2 = unit_vec(fdir[1]);
471 Ifile <<
"rectangle:\n";
474 Ifile <<
"dir1,2(directions of sides):\n" << f.
dir1 << f.
dir2;
475 Ifile <<
"dim (dimensions):" << f.
dim[0] <<
' ' << f.
dim[1] <<
'\n';
476 file << static_cast<const polygon&>(f);
494 rv.
turn(axis, angle);
519 :
polygon(), piv(fpiv), dir1(unit_vec(fdir1)), dir2(unit_vec(fdir2)) {
526 *
this =
spquadr(fpiv, sl1, sl2, fdir1, fdir2, plgn);
530 Ifile <<
"spquadr:\n";
539 file << static_cast<const polygon&>(p);
#define check_econd11(a, signb, stream)
#define check_econd11a(a, signb, add, stream)
Active pointer or automatic container or controlling pointer.
Plane, defined by defined by a point and a vector normal to the plane.
point cross(const straight &sl) const
int check_point_in(const point &fp, vfloat prec) const
int range(const point &fpt, const vec &dir, vfloat &rng, point &fptenr, vfloat prec) const
int check_point_in(const point &fpt, vfloat prec) const
polygon & operator=(const polygon &fpl)
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
polyline_pl & operator=(const polyline_pl &fpl)
static absrefabsref::* aref_pl
polyline & operator=(const polyline &fpl)
void polyline_init(const point *fpt, int fqpt)
straight Gsl(int n) const
vfloat dist_two_inter(polyline &pl, vfloat prec) const
Distance between two intervals.
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
friend int plane::cross(const polyline &pll, point *crpt, int &qcrpt, polyline *crpll, int &qcrpll, vfloat prec) const
int check_point_in(const point &fpt, vfloat prec) const
vfloat distance(const point &fpt) const
static absrefabsref::*[4] aref_rct
vec dir1
Directions of sides, unit length.
vec dir2
Directions of sides, unit length.
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
vfloat awidth
Width of total plane in units of radians.
point pt_angle_rad(vfloat rad, vfloat angle)
static absrefabsref::*[4] aref_sp
Definition of straight line, as combination of vector and point.
point cross(const straight &sl, vfloat prec) const
vfloat distance(const straight &sl, int &type_of_cross, point pt[2]) const
void turn(const vec &dir, vfloat angle)
Turn this vector.
vfloat ang2projvec(const vec &r1, const vec &r2, const vec &normal)
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
bool apeq(const circumf &f1, const circumf &f2, vfloat prec)
DoubleAc fabs(const DoubleAc &f)
int cross4pllines(const polyline pl[4], vfloat precision, straight &sl, point ptc[4][2])
#define pvecerror(string)