diff --git a/uppsrc/Core/Util.h b/uppsrc/Core/Util.h index 672abcd04..0c2fba336 100644 --- a/uppsrc/Core/Util.h +++ b/uppsrc/Core/Util.h @@ -479,7 +479,7 @@ size_t SizeBySerialize(const T& cont) TimeStop tm; SizeStream szs; const_cast(cont).Serialize(szs); - return szs; + return (size_t)szs; } template diff --git a/uppsrc/Geom/fp3.cpp b/uppsrc/Geom/fp3.cpp index ba76b023a..f838ebef1 100644 --- a/uppsrc/Geom/fp3.cpp +++ b/uppsrc/Geom/fp3.cpp @@ -33,7 +33,7 @@ Pointf3 Orthogonal(Pointf3 v, Pointf3 against) Pointf3 Orthonormal(Pointf3 v, Pointf3 against) { - return Unit(Orthogonal(v, against)); + return UnitV(Orthogonal(v, against)); } Pointf3 FarthestAxis(Pointf3 v) @@ -94,7 +94,7 @@ double Angle(Pointf3 a, Pointf3 b) ////////////////////////////////////////////////////////////////////// // Plane3:: -Plane3 Unit(Plane3 p) +Plane3 Unit3(Plane3 p) { double nt = max(Length(p.normal), fpabsmax(p.normal)); if(nt) @@ -253,7 +253,7 @@ double Matrixf3Measure(const Matrixf3& mx) Matrixf3 Matrixf3Rotate(Pointf3 axis, double angle) { Matrixf3 to_space = Matrixf3_1(); - to_space.z = Unit(axis); + to_space.z = UnitV(axis); to_space.y = Orthonormal(FarthestAxis(to_space.z), to_space.z); to_space.x = to_space.y % to_space.z; double ca = cos(angle), sa = sin(angle); @@ -292,13 +292,13 @@ void Camera::Serialize(Stream& stream) void Camera::Update() { - direction = Unit(target - location); + direction = UnitV(target - location); distance_delta = -(location ^ direction); viewing_distance = double(min(width_mm, height_mm) / (2e3 * tan(viewing_angle / 2.0))); Pointf3 up = Orthogonal(upwards, direction); if(Squared(up) <= 1e-10) up = Orthogonal(FarthestAxis(direction), direction); - straight_up = Unit(up); + straight_up = UnitV(up); straight_right = direction % straight_up; camera_matrix = Matrixf3(straight_right, straight_up, direction, location); invcam_matrix = Matrixf3Inverse(camera_matrix); @@ -327,11 +327,11 @@ void Camera::SetPolar(Pointf3 dz, Pointf3 dx, double d, double a, double b, doub Pointf3 az = RotateX(Pointf3(0, 0, -1), -b); az = d * RotateY(az, a); Pointf3 loc = az * Matrixf3(dx, dy, dz, target); - Pointf3 dir = Unit(target - loc); + Pointf3 dir = UnitV(target - loc); Pointf3 su = Orthogonal(dy, dir); if(Length(su) <= 1e-10) su = Orthogonal(FarthestAxis(dir), dir); - su = Unit(su); + su = UnitV(su); Location(loc).Upwards(Rotate(su, dir, r)); } diff --git a/uppsrc/Geom/fp3.h b/uppsrc/Geom/fp3.h index c3b714d2c..55ec342b0 100644 --- a/uppsrc/Geom/fp3.h +++ b/uppsrc/Geom/fp3.h @@ -66,7 +66,7 @@ inline double Squared(Pointf3 p) { return p.x * p inline double Length(Pointf3 p) { return sqrt(Squared(p)); } extern Pointf3 Length(Pointf3 p, double l); inline double Distance(Pointf3 p, Pointf3 q) { return Length(p - q); } -inline Pointf3 Unit(Pointf3 p) { return Length(p, 1.0); } +inline Pointf3 UnitV(Pointf3 p) { return Length(p, 1.0); } inline Pointf3 Scale(Pointf3 p, double d, Pointf3 c = Pointf(0, 0)) { return (p - c) * d + c; } inline double Determinant(Pointf3 a, Pointf3 b, Pointf3 c) { return (a % b) ^ c; } extern Pointf3 Bezier2(Pointf3 a, Pointf3 b, Pointf3 c, double t); @@ -123,7 +123,7 @@ inline Plane3& operator -= (Plane3& p, Pointf3 v) { p.delta -= inline Plane3 operator + (Plane3 p, Pointf3 v) { Plane3 r = p; r += v; return r; } inline Plane3 operator - (Plane3 p, Pointf3 v) { Plane3 r = p; r -= v; return r; } -extern Plane3 Unit(Plane3 p); +extern Plane3 Unit3(Plane3 p); struct Matrixf3; diff --git a/uppsrc/Geom/geometry.cpp b/uppsrc/Geom/geometry.cpp index 5b1ce4703..35943f5fe 100644 --- a/uppsrc/Geom/geometry.cpp +++ b/uppsrc/Geom/geometry.cpp @@ -78,7 +78,7 @@ Sizef Orthogonal(const Sizef& v, const Sizef& against) Sizef Orthonormal(const Sizef& v, const Sizef& against) { - return Unit(Orthogonal(v, against)); + return UnitV(Orthogonal(v, against)); } Sizef GetFarthestAxis(const Sizef& v) diff --git a/uppsrc/Geom/geometry.h b/uppsrc/Geom/geometry.h index 073f2a075..97dd5c3e6 100644 --- a/uppsrc/Geom/geometry.h +++ b/uppsrc/Geom/geometry.h @@ -38,7 +38,7 @@ inline Pointf Move (const Pointf& p, double dx, double dy) { return Po inline Pointf Mid (const Pointf& p, const Pointf& q, double wt) { return p + (q - p) * wt; } inline double Squared (const Pointf& p, const Pointf& q) { return Squared(q - p); } Pointf Length (const Pointf& p, double l); -inline Pointf Unit (const Pointf& p) { return Length(p, 1); } +inline Pointf UnitV (const Pointf& p) { return Length(p, 1); } inline Pointf Rotated (const Pointf& p, double a) { double s = sin(a), c = cos(a); return Pointf(p.x * c - p.y * s, p.x * s + p.y * c); } inline Pointf Rotated (const Pointf& p, double angle, const Pointf& c) { return c + Rotated(p - c, angle); } Pointf Project (const Pointf& p, const Pointf& a, const Pointf& b); @@ -91,7 +91,7 @@ inline Sizef Mid (const Sizef& p, const Sizef& q) { return Sizef(( inline double Squared (const Sizef& p, const Sizef& q) { return Squared(q - p); } //inline double Length (Sizef p) { return sqrt(Squared(p)); } Sizef Length (const Sizef& p, double l); -inline Sizef Unit (const Sizef& p) { return Length(p, 1); } +inline Sizef UnitV (const Sizef& p) { return Length(p, 1); } inline Sizef Reversed (const Sizef& s) { return Sizef(-s.cx, -s.cy); } inline Sizef ReversedX (const Sizef& s) { return Sizef(-s.cx, s.cy); } inline Sizef ReversedY (const Sizef& s) { return Sizef(s.cx, -s.cy); } diff --git a/uppsrc/Geom/vecalg.cpp b/uppsrc/Geom/vecalg.cpp index f792d23c5..b87a3261d 100644 --- a/uppsrc/Geom/vecalg.cpp +++ b/uppsrc/Geom/vecalg.cpp @@ -1221,7 +1221,7 @@ Pointf VecArcInfo::CentreOfMass() const if(!IsCurved()) return M; double extrusion = bow / (beta - alpha) - radius + fabs(bulge); - return M + Unit(IsReversed() ? UPP::Left(M) : UPP::Right(M)) * extrusion; + return M + UnitV(IsReversed() ? UPP::Left(M) : UPP::Right(M)) * extrusion; } ////////////////////////////////////////////////////////////////////// @@ -1527,8 +1527,8 @@ VecArcInfo VecArcInfo::Offset(double dist) const { if(dist == 0) return *this; - Pointf last = A + UPP::Unit(UPP::Right(GetStartDir())) * dist; - Pointf next = B + UPP::Unit(UPP::Right(GetEndDir())) * dist; + Pointf last = A + UPP::UnitV(UPP::Right(GetStartDir())) * dist; + Pointf next = B + UPP::UnitV(UPP::Right(GetEndDir())) * dist; if(IsCurved()) return VecArcInfo(C, last, next, !IsReversed()); else @@ -1738,7 +1738,7 @@ bool VecIntersection::CC(const Pointf& C1, double r1, const Pointf& C2, double r if(r > tol2) { // two solutions - Pointf D = Unit(Right(CC)) * sqrt(r); + Pointf D = UnitV(Right(CC)) * sqrt(r); count = 2; t[0] = Bearing(CP1 + D) / TWOPI; u[0] = Bearing(CP2 + D) / TWOPI;