Removed Math::Point and minor refactor
parent
431416d75e
commit
70151279f6
|
@ -180,7 +180,6 @@ add_library(colobotbase STATIC
|
|||
math/half.cpp
|
||||
math/half.h
|
||||
math/matrix.h
|
||||
math/point.h
|
||||
math/sphere.h
|
||||
math/vector.h
|
||||
object/auto/auto.cpp
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "common/key.h"
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include "math/point.h"
|
||||
#include "math/vector.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "graphics/core/color.h"
|
||||
|
||||
#include "math/point.h"
|
||||
#include "math/vector.h"
|
||||
|
||||
#include <vector>
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "graphics/core/vertex.h"
|
||||
|
||||
#include "math/matrix.h"
|
||||
#include "math/point.h"
|
||||
#include "math/sphere.h"
|
||||
#include "math/vector.h"
|
||||
|
||||
|
|
|
@ -30,6 +30,5 @@
|
|||
#include "math/geometry.h"
|
||||
#include "math/half.h"
|
||||
#include "math/matrix.h"
|
||||
#include "math/point.h"
|
||||
#include "math/vector.h"
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "math/const.h"
|
||||
#include "math/func.h"
|
||||
#include "math/matrix.h"
|
||||
#include "math/point.h"
|
||||
#include "math/vector.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
@ -239,10 +238,10 @@ inline float RotateAngle(float x, float y)
|
|||
*/
|
||||
inline float RotateAngle(const glm::vec2¢er, const glm::vec2&p1, const glm::vec2&p2)
|
||||
{
|
||||
if (PointsEqual(p1, center))
|
||||
if (glm::all(glm::epsilonEqual(p1, center, TOLERANCE)))
|
||||
return 0;
|
||||
|
||||
if (PointsEqual(p2, center))
|
||||
if (glm::all(glm::epsilonEqual(p2, center, TOLERANCE)))
|
||||
return 0;
|
||||
|
||||
float a1 = asinf((p1.y - center.y) / glm::distance(p1, center));
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2021, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file math/point.h
|
||||
* \brief Point struct and related functions
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "math/const.h"
|
||||
#include "math/func.h"
|
||||
|
||||
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
|
||||
// Math module namespace
|
||||
namespace Math
|
||||
{
|
||||
|
||||
|
||||
// Temporary type alias
|
||||
using Point = glm::vec2;
|
||||
|
||||
|
||||
//! Returns a string "[x, y]"
|
||||
inline std::string ToString(const Point& point)
|
||||
{
|
||||
std::stringstream s;
|
||||
s.precision(3);
|
||||
s << "[" << point.x << ", " << point.y << "]";
|
||||
return s.str();
|
||||
}
|
||||
|
||||
//! Checks if two vectors are equal within given \a tolerance
|
||||
inline bool PointsEqual(const Point &a, const Point &b, float tolerance = TOLERANCE)
|
||||
{
|
||||
return IsEqual(a.x, b.x, tolerance) && IsEqual(a.y, b.y, tolerance);
|
||||
}
|
||||
|
||||
//! Permutes two points
|
||||
inline void Swap(Point &a, Point &b)
|
||||
{
|
||||
Point c;
|
||||
|
||||
c = a;
|
||||
a = b;
|
||||
b = c;
|
||||
}
|
||||
|
||||
//! Returns the distance between two points
|
||||
inline float Distance(const Point &a, const Point &b)
|
||||
{
|
||||
return sqrtf((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
|
||||
}
|
||||
|
||||
|
||||
} // namespace Math
|
||||
|
Loading…
Reference in New Issue