Ticket #3588: geometry.patch
File geometry.patch, 1.7 KB (added by , 8 years ago) |
---|
-
source/simulation2/helpers/Geometry.cpp
19 19 20 20 #include "Geometry.h" 21 21 22 #include "maths/FixedVector2D.h"23 24 22 using namespace Geometry; 25 23 26 24 // TODO: all of these things could be optimised quite easily 27 25 28 bool Geometry::PointIsInSquare(CFixedVector2D point, CFixedVector2D u, CFixedVector2D v, CFixedVector2D halfSize)29 {30 fixed du = point.Dot(u);31 if (-halfSize.X <= du && du <= halfSize.X)32 {33 fixed dv = point.Dot(v);34 if (-halfSize.Y <= dv && dv <= halfSize.Y)35 return true;36 }37 return false;38 }39 40 26 CFixedVector2D Geometry::GetHalfBoundingBox(CFixedVector2D u, CFixedVector2D v, CFixedVector2D halfSize) 41 27 { 42 28 return CFixedVector2D( -
source/simulation2/helpers/Geometry.h
26 26 #include "maths/Fixed.h" 27 27 #include "maths/MathUtil.h" 28 28 29 #include "maths/FixedVector2D.h" 30 29 31 class CFixedVector2D; 30 32 31 33 namespace Geometry … … 40 42 * 41 43 * The @p u and @p v vectors must be perpendicular. 42 44 */ 43 bool PointIsInSquare(CFixedVector2D point, 44 CFixedVector2D u, CFixedVector2D v, CFixedVector2D halfSize); 45 inline bool PointIsInSquare(CFixedVector2D point, CFixedVector2D u, CFixedVector2D v, CFixedVector2D halfSize) { 46 if (point.Dot(u).Absolute() <= halfSize.X) 47 return point.Dot(v).Absolute() <= halfSize.Y; 45 48 49 return false; 50 } 51 46 52 /** 47 53 * Returns a vector (bx,by) such that every point inside 48 54 * the given rotated rectangle has coordinates