本文整理汇总了C++中Point2d::Plus方法的典型用法代码示例。如果您正苦于以下问题:C++ Point2d::Plus方法的具体用法?C++ Point2d::Plus怎么用?C++ Point2d::Plus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point2d
的用法示例。
在下文中一共展示了Point2d::Plus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EdgeNormalsWithinSurface
void SSurface::EdgeNormalsWithinSurface(Point2d auv, Point2d buv,
Vector *pt,
Vector *enin, Vector *enout,
Vector *surfn,
uint32_t auxA,
SShell *shell, SShell *sha, SShell *shb)
{
// the midpoint of the edge
Point2d muv = (auv.Plus(buv)).ScaledBy(0.5);
*pt = PointAt(muv);
// If this edge just approximates a curve, then refine our midpoint so
// so that it actually lies on that curve too. Otherwise stuff like
// point-on-face tests will fail, since the point won't actually lie
// on the other face.
hSCurve hc = { auxA };
SCurve *sc = shell->curve.FindById(hc);
if(sc->isExact && sc->exact.deg != 1) {
double t;
sc->exact.ClosestPointTo(*pt, &t, false);
*pt = sc->exact.PointAt(t);
ClosestPointTo(*pt, &muv);
} else if(!sc->isExact) {
SSurface *trimmedA = sc->GetSurfaceA(sha, shb),
*trimmedB = sc->GetSurfaceB(sha, shb);
*pt = trimmedA->ClosestPointOnThisAndSurface(trimmedB, *pt);
ClosestPointTo(*pt, &muv);
}
*surfn = NormalAt(muv.x, muv.y);
// Compute the edge's inner normal in xyz space.
Vector ab = (PointAt(auv)).Minus(PointAt(buv)),
enxyz = (ab.Cross(*surfn)).WithMagnitude(SS.ChordTolMm());
// And based on that, compute the edge's inner normal in uv space. This
// vector is perpendicular to the edge in xyz, but not necessarily in uv.
Vector tu, tv;
TangentsAt(muv.x, muv.y, &tu, &tv);
Point2d enuv;
enuv.x = enxyz.Dot(tu) / tu.MagSquared();
enuv.y = enxyz.Dot(tv) / tv.MagSquared();
// Compute the inner and outer normals of this edge (within the srf),
// in xyz space. These are not necessarily antiparallel, if the
// surface is curved.
Vector pin = PointAt(muv.Minus(enuv)),
pout = PointAt(muv.Plus(enuv));
*enin = pin.Minus(*pt),
*enout = pout.Minus(*pt);
}
示例2: min
double Point2d::DistanceToLine(Point2d p0, Point2d dp, bool segment) {
double m = dp.x*dp.x + dp.y*dp.y;
if(m < LENGTH_EPS*LENGTH_EPS) return VERY_POSITIVE;
// Let our line be p = p0 + t*dp, for a scalar t from 0 to 1
double t = (dp.x*(x - p0.x) + dp.y*(y - p0.y))/m;
if((t < 0 || t > 1) && segment) {
// The closest point is one of the endpoints; determine which.
double d0 = DistanceTo(p0);
double d1 = DistanceTo(p0.Plus(dp));
return min(d1, d0);
} else {
Point2d closest = p0.Plus(dp.ScaledBy(t));
return DistanceTo(closest);
}
}
示例3: AllPointsIntersecting
//-----------------------------------------------------------------------------
// Find all points where a line through a and b intersects our surface, and
// add them to the list. If seg is true then report only intersections that
// lie within the finite line segment (not including the endpoints); otherwise
// we work along the infinite line. And we report either just intersections
// inside the trim curve, or any intersection with u, v in [0, 1]. And we
// either disregard or report tangent points.
//-----------------------------------------------------------------------------
void SSurface::AllPointsIntersecting(Vector a, Vector b,
List<SInter> *l,
bool seg, bool trimmed, bool inclTangent)
{
if(LineEntirelyOutsideBbox(a, b, seg)) return;
Vector ba = b.Minus(a);
double bam = ba.Magnitude();
List<Inter> inters;
ZERO(&inters);
// All the intersections between the line and the surface; either special
// cases that we can quickly solve in closed form, or general numerical.
Vector center, axis, start, finish;
double radius;
if(degm == 1 && degn == 1) {
// Against a plane, easy.
Vector n = NormalAt(0, 0).WithMagnitude(1);
double d = n.Dot(PointAt(0, 0));
// Trim to line segment now if requested, don't generate points that
// would just get discarded later.
if(!seg ||
(n.Dot(a) > d + LENGTH_EPS && n.Dot(b) < d - LENGTH_EPS) ||
(n.Dot(b) > d + LENGTH_EPS && n.Dot(a) < d - LENGTH_EPS))
{
Vector p = Vector::AtIntersectionOfPlaneAndLine(n, d, a, b, NULL);
Inter inter;
ClosestPointTo(p, &(inter.p.x), &(inter.p.y));
inters.Add(&inter);
}
} else if(IsCylinder(&axis, ¢er, &radius, &start, &finish)) {
// This one can be solved in closed form too.
Vector ab = b.Minus(a);
if(axis.Cross(ab).Magnitude() < LENGTH_EPS) {
// edge is parallel to axis of cylinder, no intersection points
return;
}
// A coordinate system centered at the center of the circle, with
// the edge under test horizontal
Vector u, v, n = axis.WithMagnitude(1);
u = (ab.Minus(n.ScaledBy(ab.Dot(n)))).WithMagnitude(1);
v = n.Cross(u);
Point2d ap = (a.Minus(center)).DotInToCsys(u, v, n).ProjectXy(),
bp = (b.Minus(center)).DotInToCsys(u, v, n).ProjectXy(),
sp = (start. Minus(center)).DotInToCsys(u, v, n).ProjectXy(),
fp = (finish.Minus(center)).DotInToCsys(u, v, n).ProjectXy();
double thetas = atan2(sp.y, sp.x), thetaf = atan2(fp.y, fp.x);
Point2d ip[2];
int ip_n = 0;
if(fabs(fabs(ap.y) - radius) < LENGTH_EPS) {
// tangent
if(inclTangent) {
ip[0] = Point2d::From(0, ap.y);
ip_n = 1;
}
} else if(fabs(ap.y) < radius) {
// two intersections
double xint = sqrt(radius*radius - ap.y*ap.y);
ip[0] = Point2d::From(-xint, ap.y);
ip[1] = Point2d::From( xint, ap.y);
ip_n = 2;
}
int i;
for(i = 0; i < ip_n; i++) {
double t = (ip[i].Minus(ap)).DivPivoting(bp.Minus(ap));
// This is a point on the circle; but is it on the arc?
Point2d pp = ap.Plus((bp.Minus(ap)).ScaledBy(t));
double theta = atan2(pp.y, pp.x);
double dp = WRAP_SYMMETRIC(theta - thetas, 2*PI),
df = WRAP_SYMMETRIC(thetaf - thetas, 2*PI);
double tol = LENGTH_EPS/radius;
if((df > 0 && ((dp < -tol) || (dp > df + tol))) ||
(df < 0 && ((dp > tol) || (dp < df - tol))))
{
continue;
}
Vector p = a.Plus((b.Minus(a)).ScaledBy(t));
Inter inter;
ClosestPointTo(p, &(inter.p.x), &(inter.p.y));
inters.Add(&inter);
}
} else {
// General numerical solution by subdivision, fallback
int cnt = 0, level = 0;
AllPointsIntersectingUntrimmed(a, b, &cnt, &level, &inters, seg, this);
}
//.........这里部分代码省略.........