Ticket #3588: geometry.patch

File geometry.patch, 1.7 KB (added by mimo, 8 years ago)

inlining of Geometry::PointIsInSquare

  • source/simulation2/helpers/Geometry.cpp

     
    1919
    2020#include "Geometry.h"
    2121
    22 #include "maths/FixedVector2D.h"
    23 
    2422using namespace Geometry;
    2523
    2624// TODO: all of these things could be optimised quite easily
    2725
    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 
    4026CFixedVector2D Geometry::GetHalfBoundingBox(CFixedVector2D u, CFixedVector2D v, CFixedVector2D halfSize)
    4127{
    4228    return CFixedVector2D(
  • source/simulation2/helpers/Geometry.h

     
    2626#include "maths/Fixed.h"
    2727#include "maths/MathUtil.h"
    2828
     29#include "maths/FixedVector2D.h"
     30
    2931class CFixedVector2D;
    3032
    3133namespace Geometry
     
    4042 *
    4143 * The @p u and @p v vectors must be perpendicular.
    4244 */
    43 bool PointIsInSquare(CFixedVector2D point,
    44     CFixedVector2D u, CFixedVector2D v, CFixedVector2D halfSize);
     45inline 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;
    4548
     49    return false;
     50}
     51
    4652/**
    4753 * Returns a vector (bx,by) such that every point inside
    4854 * the given rotated rectangle has coordinates