载入中...
搜索中...
未找到
UrbanGeometry.cpp 文件参考
#include "procgen/urban/UrbanGeometry.h"
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>

浏览源代码.

命名空间

namespace  eve
 Build metadata (engine git commit, build time, third-party version).
 
namespace  eve::procgen
 
namespace  eve::procgen::urban
 

函数

double eve::procgen::urban::signedArea (const Polygon &poly)
 Return the raw (possibly negative) signed area of a polygon ring.
 
double eve::procgen::urban::area (const Polygon &poly)
 Absolute polygon area.
 
double eve::procgen::urban::polylineLength (const Polyline &pl)
 Total length of an open polyline.
 
Vec2 eve::procgen::urban::centroid (const Polygon &poly)
 Centroid (area-weighted) of a simple polygon.
 
double eve::procgen::urban::perimeter (const Polygon &poly)
 Perimeter length of a closed ring.
 
bool eve::procgen::urban::ensureCCW (Polygon &poly)
 Ensure the ring is CCW (positive signed area); returns whether it was flipped.
 
void eve::procgen::urban::cleanupRing (Polygon &poly, double eps=1e-9)
 Remove consecutive duplicate points (within eps) and points that create zero spikes.
 
bool eve::procgen::urban::pointInPolygon (const Vec2 &p, const Polygon &poly)
 Point-in-polygon test (ray casting; boundary counts as inside).
 
bool eve::procgen::urban::pointOnSegment (const Vec2 &p, const Vec2 &a, const Vec2 &b, double eps=1e-9)
 True if p lies on segment a-b (within tolerance).
 
bool eve::procgen::urban::segmentsIntersect (const Vec2 &a, const Vec2 &b, const Vec2 &c, const Vec2 &d, Vec2 *out)
 True if the open segments a-b and c-d properly cross; out receives the crossing.
 
bool eve::procgen::urban::segmentIntersectsPolyline (const Vec2 &a, const Vec2 &b, const Polyline &pl)
 True if a segment crosses any segment of an open polyline (excluding shared endpoints).
 
bool eve::procgen::urban::polylineSelfIntersects (const Polyline &pl)
 True if any two non-adjacent segments of the open polyline cross.
 
bool eve::procgen::urban::polygonIsSimple (const Polygon &poly)
 Simple polygon test: no self intersections among non-adjacent ring edges.
 
double eve::procgen::urban::closestPointOnSegment (const Vec2 &p, const Vec2 &a, const Vec2 &b, Vec2 *out)
 Closest point on segment a-b; returns distance and writes out.
 
Vec2 eve::procgen::urban::closestPointOnBoundary (const Polygon &poly, const Vec2 &p, BoundaryPosition *pos)
 Closest point on the polygon boundary; writes edge index + t in [0,1].
 
Vec2 eve::procgen::urban::pointAtBoundaryLength (const Polygon &poly, double s, BoundaryPosition *pos)
 Interpolate the boundary point at arc length s in [0, perimeter).
 
std::vector< BoundarySample > eve::procgen::urban::sampleBoundary (const Polygon &poly, int count)
 Uniformly sample the polygon boundary (approx. count samples, at least 8). Samples are ordered along the boundary; each stores the tangent angle in radians.
 
double eve::procgen::urban::includedAngleDeg (const Vec2 &u, const Vec2 &v)
 Included angle in degrees at the shared vertex between edge u (prev->shared) and v (shared->next), in [0,180].
 
bool eve::procgen::urban::isCollinear (const Vec2 &prev, const Vec2 &shared, const Vec2 &next)
 True when two consecutive edges are considered collinear (included angle > 135°).
 
Polygon eve::procgen::urban::approximatePolygon (const Polygon &ring)
 Simplify a ring to its approximate polygon: consecutive edges with included angle > 135° are merged into a single side (paper Section 3).
 
double eve::procgen::urban::shapeIrregularity (const Polygon &approxRing, double gammaAngle=0.75, double gammaSide=0.25)
 Shape irregularity metric of Eq. (1) over the approximate polygon: I = γ1·(1/N)·Σ(θi−θ̄)² + γ2·(1/(N·l̄²))·Σ(li−l̄)². Smaller is more regular; 0 for an ideal regular polygon.
 
bool eve::procgen::urban::splitPolygonByPolyline (const Polygon &poly, const Polyline &split, const BoundaryPosition &posA, const BoundaryPosition &posB, Polygon &outA, Polygon &outB)
 Split a CCW simple polygon by a polyline whose endpoints lie on the boundary and whose interior points are strictly inside the polygon. split goes from boundary point A to boundary point B; the two resulting CCW rings are returned in outA/outB. Returns false on degenerate input. Callers verify area constraints afterwards.
 
bool eve::procgen::urban::validSplit (const Polygon &poly, const Polyline &split, double minHalfArea, Polygon *outA, Polygon *outB, double *fracA)
 Validity of a candidate split: both halves simple, positive area, inside the original.
 
bool eve::procgen::urban::triangulatePolygon (const Polygon &poly, std::vector< int > &outTriangles)
 Triangulate a simple polygon by ear clipping; returns CCW triangles (3*i..3*i+2).
 
double eve::procgen::urban::distanceToSegment (const Vec2 &p, const Vec2 &a, const Vec2 &b)
 Raster helper: does the pixel-center fall within eps of segment a-b?