Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/helpers/Geometry.h
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
* The rectangle is defined by the four vertexes | * The rectangle is defined by the four vertexes | ||||
* (+/-u*halfSize.X +/-v*halfSize.Y). | * (+/-u*halfSize.X +/-v*halfSize.Y). | ||||
* | * | ||||
* The @p u and @p v vectors must be perpendicular and unit length. | * The @p u and @p v vectors must be perpendicular and unit length. | ||||
*/ | */ | ||||
CFixedVector2D NearestPointOnSquare(const CFixedVector2D& point, | CFixedVector2D NearestPointOnSquare(const CFixedVector2D& point, | ||||
const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize); | const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize); | ||||
/** | |||||
* Returns the shortest distance between two squares. | |||||
*/ | |||||
fixed DistanceSquareToSquare(const CFixedVector2D& relativePos, | |||||
const CFixedVector2D& u1, const CFixedVector2D& v1, const CFixedVector2D& halfSize1, | |||||
const CFixedVector2D& u2, const CFixedVector2D& v2, const CFixedVector2D& halfSize2); | |||||
/** | |||||
* Returns the greatest straight line distance from a point to a square. | |||||
* | |||||
* If @p countInsideAsZero is true, and the point is inside the rectangle, | |||||
* it will return 0. | |||||
* If @p countInsideAsZero is false, the greatest (positive) distance to the boundary | |||||
* will be returned regardless of where the point is. | |||||
*/ | |||||
fixed MaxDistanceToSquare(const CFixedVector2D& point, | |||||
const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize, | |||||
bool countInsideAsZero = false); | |||||
/** | |||||
* Return the greatest straight line distance between two squares. | |||||
*/ | |||||
fixed MaxDistanceSquareToSquare(const CFixedVector2D& relativePos, | |||||
const CFixedVector2D& u1, const CFixedVector2D& v1, const CFixedVector2D& halfSize1, | |||||
const CFixedVector2D& u2, const CFixedVector2D& v2, const CFixedVector2D& halfSize2); | |||||
bool TestRaySquare(const CFixedVector2D& a, const CFixedVector2D& b, const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize); | bool TestRaySquare(const CFixedVector2D& a, const CFixedVector2D& b, const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize); | ||||
bool TestRayAASquare(const CFixedVector2D& a, const CFixedVector2D& b, const CFixedVector2D& halfSize); | bool TestRayAASquare(const CFixedVector2D& a, const CFixedVector2D& b, const CFixedVector2D& halfSize); | ||||
bool TestSquareSquare( | bool TestSquareSquare( | ||||
const CFixedVector2D& c0, const CFixedVector2D& u0, const CFixedVector2D& v0, const CFixedVector2D& halfSize0, | const CFixedVector2D& c0, const CFixedVector2D& u0, const CFixedVector2D& v0, const CFixedVector2D& halfSize0, | ||||
const CFixedVector2D& c1, const CFixedVector2D& u1, const CFixedVector2D& v1, const CFixedVector2D& halfSize1); | const CFixedVector2D& c1, const CFixedVector2D& u1, const CFixedVector2D& v1, const CFixedVector2D& halfSize1); | ||||
Show All 19 Lines |
Wildfire Games · Phabricator