diff options
Diffstat (limited to 'core/math')
-rw-r--r-- | core/math/a_star.cpp | 2 | ||||
-rw-r--r-- | core/math/aabb.h | 2 | ||||
-rw-r--r-- | core/math/basis.cpp | 19 | ||||
-rw-r--r-- | core/math/basis.h | 4 | ||||
-rw-r--r-- | core/math/bvh_logic.inc | 50 | ||||
-rw-r--r-- | core/math/camera_matrix.cpp | 22 | ||||
-rw-r--r-- | core/math/convex_hull.cpp | 18 | ||||
-rw-r--r-- | core/math/face3.h | 14 | ||||
-rw-r--r-- | core/math/math_defs.h | 8 | ||||
-rw-r--r-- | core/math/math_funcs.h | 8 | ||||
-rw-r--r-- | core/math/plane.cpp | 2 | ||||
-rw-r--r-- | core/math/rect2.h | 10 | ||||
-rw-r--r-- | core/math/transform_2d.cpp | 4 | ||||
-rw-r--r-- | core/math/transform_2d.h | 2 | ||||
-rw-r--r-- | core/math/transform_3d.cpp | 6 | ||||
-rw-r--r-- | core/math/triangulate.cpp | 11 | ||||
-rw-r--r-- | core/math/vector2.cpp | 9 | ||||
-rw-r--r-- | core/math/vector3.cpp | 9 |
18 files changed, 94 insertions, 106 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index d59dbf1ba8..1079da75ef 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -239,7 +239,7 @@ bool AStar::are_points_connected(int p_id, int p_with_id, bool bidirectional) co const Set<Segment>::Element *element = segments.find(s); return element != nullptr && - (bidirectional || (element->get().direction & s.direction) == s.direction); + (bidirectional || (element->get().direction & s.direction) == s.direction); } void AStar::clear() { diff --git a/core/math/aabb.h b/core/math/aabb.h index 97d92fbe37..c458e61475 100644 --- a/core/math/aabb.h +++ b/core/math/aabb.h @@ -200,7 +200,7 @@ Vector3 AABB::get_support(const Vector3 &p_normal) const { (p_normal.x > 0) ? half_extents.x : -half_extents.x, (p_normal.y > 0) ? half_extents.y : -half_extents.y, (p_normal.z > 0) ? half_extents.z : -half_extents.z) + - ofs; + ofs; } Vector3 AABB::get_endpoint(int p_point) const { diff --git a/core/math/basis.cpp b/core/math/basis.cpp index 0030cb1144..3d893afb4d 100644 --- a/core/math/basis.cpp +++ b/core/math/basis.cpp @@ -58,8 +58,8 @@ void Basis::invert() { cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1) }; real_t det = elements[0][0] * co[0] + - elements[0][1] * co[1] + - elements[0][2] * co[2]; + elements[0][1] * co[1] + + elements[0][2] * co[2]; #ifdef MATH_CHECKS ERR_FAIL_COND(det == 0); #endif @@ -288,10 +288,7 @@ Vector3 Basis::get_scale() const { // // The rotation part of this decomposition is returned by get_rotation* functions. real_t det_sign = SGN(determinant()); - return det_sign * Vector3( - Vector3(elements[0][0], elements[1][0], elements[2][0]).length(), - Vector3(elements[0][1], elements[1][1], elements[2][1]).length(), - Vector3(elements[0][2], elements[1][2], elements[2][2]).length()); + return det_sign * get_scale_abs(); } // Decomposes a Basis into a rotation-reflection matrix (an element of the group O(3)) and a positive scaling matrix as B = O.S. @@ -682,8 +679,8 @@ bool Basis::operator!=(const Basis &p_matrix) const { Basis::operator String() const { return "[X: " + get_axis(0).operator String() + - ", Y: " + get_axis(1).operator String() + - ", Z: " + get_axis(2).operator String() + "]"; + ", Y: " + get_axis(1).operator String() + + ", Z: " + get_axis(2).operator String() + "]"; } Quaternion Basis::get_quaternion() const { @@ -704,9 +701,9 @@ Quaternion Basis::get_quaternion() const { temp[1] = ((m.elements[0][2] - m.elements[2][0]) * s); temp[2] = ((m.elements[1][0] - m.elements[0][1]) * s); } else { - int i = m.elements[0][0] < m.elements[1][1] ? - (m.elements[1][1] < m.elements[2][2] ? 2 : 1) : - (m.elements[0][0] < m.elements[2][2] ? 2 : 0); + int i = m.elements[0][0] < m.elements[1][1] + ? (m.elements[1][1] < m.elements[2][2] ? 2 : 1) + : (m.elements[0][0] < m.elements[2][2] ? 2 : 0); int j = (i + 1) % 3; int k = (i + 2) % 3; diff --git a/core/math/basis.h b/core/math/basis.h index 617d005f19..e2fdb95685 100644 --- a/core/math/basis.h +++ b/core/math/basis.h @@ -324,7 +324,7 @@ Vector3 Basis::xform_inv(const Vector3 &p_vector) const { real_t Basis::determinant() const { return elements[0][0] * (elements[1][1] * elements[2][2] - elements[2][1] * elements[1][2]) - - elements[1][0] * (elements[0][1] * elements[2][2] - elements[2][1] * elements[0][2]) + - elements[2][0] * (elements[0][1] * elements[1][2] - elements[1][1] * elements[0][2]); + elements[1][0] * (elements[0][1] * elements[2][2] - elements[2][1] * elements[0][2]) + + elements[2][0] * (elements[0][1] * elements[1][2] - elements[1][1] * elements[0][2]); } #endif // BASIS_H diff --git a/core/math/bvh_logic.inc b/core/math/bvh_logic.inc index afab08f151..c65002a9fd 100644 --- a/core/math/bvh_logic.inc +++ b/core/math/bvh_logic.inc @@ -42,24 +42,24 @@ BVHABB_CLASS _logic_abb_merge(const BVHABB_CLASS &a, const BVHABB_CLASS &b) { //-------------------------------------------------------------------------------------------------- /** -@file q3DynamicAABBTree.h -@author Randy Gaul -@date 10/10/2014 - Copyright (c) 2014 Randy Gaul http://www.randygaul.net - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ + * @file q3DynamicAABBTree.h + * @author Randy Gaul + * @date 10/10/2014 + * Copyright (c) 2014 Randy Gaul http://www.randygaul.net + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ //-------------------------------------------------------------------------------------------------- // This function is based on the 'Balance' function from Randy Gaul's qu3e @@ -67,7 +67,7 @@ BVHABB_CLASS _logic_abb_merge(const BVHABB_CLASS &a, const BVHABB_CLASS &b) { // It is MODIFIED from qu3e version. // This is the only function used (and _logic_abb_merge helper function). int32_t _logic_balance(int32_t iA, uint32_t p_tree_id) { - // return iA; // uncomment this to bypass balance + //return iA; // uncomment this to bypass balance TNode *A = &_nodes[iA]; @@ -75,12 +75,12 @@ int32_t _logic_balance(int32_t iA, uint32_t p_tree_id) { return iA; } - /* A - / \ - B C - / \ / \ - D E F G - */ + /* A + * / \ + * B C + * / \ / \ + * D E F G + */ CRASH_COND(A->num_children != 2); int32_t iB = A->children[0]; diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index 8066a59281..48984c4d5b 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -35,17 +35,17 @@ float CameraMatrix::determinant() const { return matrix[0][3] * matrix[1][2] * matrix[2][1] * matrix[3][0] - matrix[0][2] * matrix[1][3] * matrix[2][1] * matrix[3][0] - - matrix[0][3] * matrix[1][1] * matrix[2][2] * matrix[3][0] + matrix[0][1] * matrix[1][3] * matrix[2][2] * matrix[3][0] + - matrix[0][2] * matrix[1][1] * matrix[2][3] * matrix[3][0] - matrix[0][1] * matrix[1][2] * matrix[2][3] * matrix[3][0] - - matrix[0][3] * matrix[1][2] * matrix[2][0] * matrix[3][1] + matrix[0][2] * matrix[1][3] * matrix[2][0] * matrix[3][1] + - matrix[0][3] * matrix[1][0] * matrix[2][2] * matrix[3][1] - matrix[0][0] * matrix[1][3] * matrix[2][2] * matrix[3][1] - - matrix[0][2] * matrix[1][0] * matrix[2][3] * matrix[3][1] + matrix[0][0] * matrix[1][2] * matrix[2][3] * matrix[3][1] + - matrix[0][3] * matrix[1][1] * matrix[2][0] * matrix[3][2] - matrix[0][1] * matrix[1][3] * matrix[2][0] * matrix[3][2] - - matrix[0][3] * matrix[1][0] * matrix[2][1] * matrix[3][2] + matrix[0][0] * matrix[1][3] * matrix[2][1] * matrix[3][2] + - matrix[0][1] * matrix[1][0] * matrix[2][3] * matrix[3][2] - matrix[0][0] * matrix[1][1] * matrix[2][3] * matrix[3][2] - - matrix[0][2] * matrix[1][1] * matrix[2][0] * matrix[3][3] + matrix[0][1] * matrix[1][2] * matrix[2][0] * matrix[3][3] + - matrix[0][2] * matrix[1][0] * matrix[2][1] * matrix[3][3] - matrix[0][0] * matrix[1][2] * matrix[2][1] * matrix[3][3] - - matrix[0][1] * matrix[1][0] * matrix[2][2] * matrix[3][3] + matrix[0][0] * matrix[1][1] * matrix[2][2] * matrix[3][3]; + matrix[0][3] * matrix[1][1] * matrix[2][2] * matrix[3][0] + matrix[0][1] * matrix[1][3] * matrix[2][2] * matrix[3][0] + + matrix[0][2] * matrix[1][1] * matrix[2][3] * matrix[3][0] - matrix[0][1] * matrix[1][2] * matrix[2][3] * matrix[3][0] - + matrix[0][3] * matrix[1][2] * matrix[2][0] * matrix[3][1] + matrix[0][2] * matrix[1][3] * matrix[2][0] * matrix[3][1] + + matrix[0][3] * matrix[1][0] * matrix[2][2] * matrix[3][1] - matrix[0][0] * matrix[1][3] * matrix[2][2] * matrix[3][1] - + matrix[0][2] * matrix[1][0] * matrix[2][3] * matrix[3][1] + matrix[0][0] * matrix[1][2] * matrix[2][3] * matrix[3][1] + + matrix[0][3] * matrix[1][1] * matrix[2][0] * matrix[3][2] - matrix[0][1] * matrix[1][3] * matrix[2][0] * matrix[3][2] - + matrix[0][3] * matrix[1][0] * matrix[2][1] * matrix[3][2] + matrix[0][0] * matrix[1][3] * matrix[2][1] * matrix[3][2] + + matrix[0][1] * matrix[1][0] * matrix[2][3] * matrix[3][2] - matrix[0][0] * matrix[1][1] * matrix[2][3] * matrix[3][2] - + matrix[0][2] * matrix[1][1] * matrix[2][0] * matrix[3][3] + matrix[0][1] * matrix[1][2] * matrix[2][0] * matrix[3][3] + + matrix[0][2] * matrix[1][0] * matrix[2][1] * matrix[3][3] - matrix[0][0] * matrix[1][2] * matrix[2][1] * matrix[3][3] - + matrix[0][1] * matrix[1][0] * matrix[2][2] * matrix[3][3] + matrix[0][0] * matrix[1][1] * matrix[2][2] * matrix[3][3]; } void CameraMatrix::set_identity() { diff --git a/core/math/convex_hull.cpp b/core/math/convex_hull.cpp index 684814b1ae..f6560f1bea 100644 --- a/core/math/convex_hull.cpp +++ b/core/math/convex_hull.cpp @@ -265,8 +265,7 @@ public: } int32_t get_sign() const { - return ((int64_t)high < 0) ? -1 : (high || low) ? 1 : - 0; + return ((int64_t)high < 0) ? -1 : ((high || low) ? 1 : 0); } bool operator<(const Int128 &b) const { @@ -735,8 +734,6 @@ int32_t ConvexHullInternal::Rational64::compare(const Rational64 &b) const { return 0; } - // return (numerator * b.denominator > b.numerator * denominator) ? sign : (numerator * b.denominator < b.numerator * denominator) ? -sign : 0; - #ifdef USE_X86_64_ASM int32_t result; @@ -757,10 +754,9 @@ int32_t ConvexHullInternal::Rational64::compare(const Rational64 &b) const { : "=&b"(result), [tmp] "=&r"(tmp), "=a"(dummy) : "a"(denominator), [bn] "g"(b.numerator), [tn] "g"(numerator), [bd] "g"(b.denominator) : "%rdx", "cc"); - return result ? result ^ sign // if sign is +1, only bit 0 of result is inverted, which does not change the sign of result (and cannot result in zero) - // if sign is -1, all bits of result are inverted, which changes the sign of result (and again cannot result in zero) - : - 0; + // if sign is +1, only bit 0 of result is inverted, which does not change the sign of result (and cannot result in zero) + // if sign is -1, all bits of result are inverted, which changes the sign of result (and again cannot result in zero) + return result ? result ^ sign : 0; #else @@ -793,8 +789,7 @@ int32_t ConvexHullInternal::Rational128::compare(const Rational128 &b) const { int32_t ConvexHullInternal::Rational128::compare(int64_t b) const { if (is_int_64) { int64_t a = sign * (int64_t)numerator.low; - return (a > b) ? 1 : (a < b) ? -1 : - 0; + return (a > b) ? 1 : ((a < b) ? -1 : 0); } if (b > 0) { if (sign <= 0) { @@ -1446,8 +1441,7 @@ void ConvexHullInternal::merge(IntermediateHull &p_h0, IntermediateHull &p_h1) { c1->edges = e; return; } else { - int32_t cmp = !min0 ? 1 : !min1 ? -1 : - min_cot0.compare(min_cot1); + int32_t cmp = !min0 ? 1 : (!min1 ? -1 : min_cot0.compare(min_cot1)); #ifdef DEBUG_CONVEX_HULL printf(" -> Result %d\n", cmp); #endif diff --git a/core/math/face3.h b/core/math/face3.h index 9e9026e54e..0a8c1c6041 100644 --- a/core/math/face3.h +++ b/core/math/face3.h @@ -48,13 +48,13 @@ public: Vector3 vertex[3]; /** - * - * @param p_plane plane used to split the face - * @param p_res array of at least 3 faces, amount used in function return - * @param p_is_point_over array of at least 3 booleans, determining which face is over the plane, amount used in function return - * @param _epsilon constant used for numerical error rounding, to add "thickness" to the plane (so coplanar points can happen) - * @return amount of faces generated by the split, either 0 (means no split possible), 2 or 3 - */ + * + * @param p_plane plane used to split the face + * @param p_res array of at least 3 faces, amount used in function return + * @param p_is_point_over array of at least 3 booleans, determining which face is over the plane, amount used in function return + * @param _epsilon constant used for numerical error rounding, to add "thickness" to the plane (so coplanar points can happen) + * @return amount of faces generated by the split, either 0 (means no split possible), 2 or 3 + */ int split_by_plane(const Plane &p_plane, Face3 *p_res, bool *p_is_point_over) const; diff --git a/core/math/math_defs.h b/core/math/math_defs.h index c3a8f910c0..900e90a598 100644 --- a/core/math/math_defs.h +++ b/core/math/math_defs.h @@ -116,10 +116,10 @@ enum Corner { }; /** - * The "Real" type is an abstract type used for real numbers, such as 1.5, - * in contrast to integer numbers. Precision can be controlled with the - * presence or absence of the REAL_T_IS_DOUBLE define. - */ + * The "Real" type is an abstract type used for real numbers, such as 1.5, + * in contrast to integer numbers. Precision can be controlled with the + * presence or absence of the REAL_T_IS_DOUBLE define. + */ #ifdef REAL_T_IS_DOUBLE typedef double real_t; #else diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 4e4f566517..baff10af98 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -159,7 +159,7 @@ public: } ieee754; ieee754.f = p_val; return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 && - ((unsigned)ieee754.u == 0); + ((unsigned)ieee754.u == 0); #else return isinf(p_val); #endif @@ -461,7 +461,7 @@ public: mantissa = 0; } hf = (((uint16_t)sign) << 15) | (uint16_t)((0x1F << 10)) | - (uint16_t)(mantissa >> 13); + (uint16_t)(mantissa >> 13); } // check if exponent is <= -15 else if (exp <= 0x38000000) { @@ -474,8 +474,8 @@ public: hf = 0; //denormals do not work for 3D, convert to zero } else { hf = (((uint16_t)sign) << 15) | - (uint16_t)((exp - 0x38000000) >> 13) | - (uint16_t)(mantissa >> 13); + (uint16_t)((exp - 0x38000000) >> 13) | + (uint16_t)(mantissa >> 13); } return hf; diff --git a/core/math/plane.cpp b/core/math/plane.cpp index 3c78b55b90..59f7918258 100644 --- a/core/math/plane.cpp +++ b/core/math/plane.cpp @@ -88,7 +88,7 @@ bool Plane::intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r *r_result = ((vec3_cross(normal1, normal2) * p_plane0.d) + (vec3_cross(normal2, normal0) * p_plane1.d) + (vec3_cross(normal0, normal1) * p_plane2.d)) / - denom; + denom; } return true; diff --git a/core/math/rect2.h b/core/math/rect2.h index 2557959fa2..26e202589d 100644 --- a/core/math/rect2.h +++ b/core/math/rect2.h @@ -118,8 +118,8 @@ struct Rect2 { inline bool encloses(const Rect2 &p_rect) const { return (p_rect.position.x >= position.x) && (p_rect.position.y >= position.y) && - ((p_rect.position.x + p_rect.size.x) <= (position.x + size.x)) && - ((p_rect.position.y + p_rect.size.y) <= (position.y + size.y)); + ((p_rect.position.x + p_rect.size.x) <= (position.x + size.x)) && + ((p_rect.position.y + p_rect.size.y) <= (position.y + size.y)); } _FORCE_INLINE_ bool has_no_area() const { @@ -257,7 +257,7 @@ struct Rect2 { return Vector2( (p_normal.x > 0) ? -half_extents.x : half_extents.x, (p_normal.y > 0) ? -half_extents.y : half_extents.y) + - ofs; + ofs; } _FORCE_INLINE_ bool intersects_filled_polygon(const Vector2 *p_points, int p_point_count) const { @@ -367,8 +367,8 @@ struct Rect2i { inline bool encloses(const Rect2i &p_rect) const { return (p_rect.position.x >= position.x) && (p_rect.position.y >= position.y) && - ((p_rect.position.x + p_rect.size.x) < (position.x + size.x)) && - ((p_rect.position.y + p_rect.size.y) < (position.y + size.y)); + ((p_rect.position.x + p_rect.size.x) < (position.x + size.x)) && + ((p_rect.position.y + p_rect.size.y) < (position.y + size.y)); } _FORCE_INLINE_ bool has_no_area() const { diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp index 496a557844..df43c605f9 100644 --- a/core/math/transform_2d.cpp +++ b/core/math/transform_2d.cpp @@ -298,6 +298,6 @@ Transform2D Transform2D::operator*(const real_t p_val) const { Transform2D::operator String() const { return "[X: " + elements[0].operator String() + - ", Y: " + elements[1].operator String() + - ", O: " + elements[2].operator String() + "]"; + ", Y: " + elements[1].operator String() + + ", O: " + elements[2].operator String() + "]"; } diff --git a/core/math/transform_2d.h b/core/math/transform_2d.h index 6ed3af2ba7..8a0e876d96 100644 --- a/core/math/transform_2d.h +++ b/core/math/transform_2d.h @@ -164,7 +164,7 @@ Vector2 Transform2D::xform(const Vector2 &p_vec) const { return Vector2( tdotx(p_vec), tdoty(p_vec)) + - elements[2]; + elements[2]; } Vector2 Transform2D::xform_inv(const Vector2 &p_vec) const { diff --git a/core/math/transform_3d.cpp b/core/math/transform_3d.cpp index 4f4943c8ef..78ef117443 100644 --- a/core/math/transform_3d.cpp +++ b/core/math/transform_3d.cpp @@ -175,9 +175,9 @@ Transform3D Transform3D::operator*(const real_t p_val) const { Transform3D::operator String() const { return "[X: " + basis.get_axis(0).operator String() + - ", Y: " + basis.get_axis(1).operator String() + - ", Z: " + basis.get_axis(2).operator String() + - ", O: " + origin.operator String() + "]"; + ", Y: " + basis.get_axis(1).operator String() + + ", Z: " + basis.get_axis(2).operator String() + + ", O: " + origin.operator String() + "]"; } Transform3D::Transform3D(const Basis &p_basis, const Vector3 &p_origin) : diff --git a/core/math/triangulate.cpp b/core/math/triangulate.cpp index fa1588dbc5..28f1d96b14 100644 --- a/core/math/triangulate.cpp +++ b/core/math/triangulate.cpp @@ -42,18 +42,13 @@ real_t Triangulate::get_area(const Vector<Vector2> &contour) { return A * 0.5; } -/* - is_inside_triangle decides if a point P is Inside of the triangle - defined by A, B, C. - */ - +/* `is_inside_triangle` decides if a point P is inside the triangle + * defined by A, B, C. */ bool Triangulate::is_inside_triangle(real_t Ax, real_t Ay, real_t Bx, real_t By, real_t Cx, real_t Cy, real_t Px, real_t Py, - bool include_edges) - -{ + bool include_edges) { real_t ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy; real_t cCROSSap, bCROSScp, aCROSSbp; diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp index 16e43d7d06..6259bdead0 100644 --- a/core/math/vector2.cpp +++ b/core/math/vector2.cpp @@ -160,10 +160,11 @@ Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, c real_t t3 = t2 * t; Vector2 out; - out = 0.5 * ((p1 * 2.0) + - (-p0 + p2) * t + - (2.0 * p0 - 5.0 * p1 + 4 * p2 - p3) * t2 + - (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); + out = 0.5 * + ((p1 * 2.0) + + (-p0 + p2) * t + + (2.0 * p0 - 5.0 * p1 + 4 * p2 - p3) * t2 + + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); return out; } diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index fa212c178a..42e3da0b27 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -93,10 +93,11 @@ Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, c real_t t3 = t2 * t; Vector3 out; - out = 0.5 * ((p1 * 2.0) + - (-p0 + p2) * t + - (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3) * t2 + - (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); + out = 0.5 * + ((p1 * 2.0) + + (-p0 + p2) * t + + (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3) * t2 + + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); return out; } |