Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
vector.cpp
Go to the documentation of this file.
1/*
2 Vector.h
3 Nicolas Chereau 2006
4 Olympe Engine ::2D Game Editor ::olympe.editor@gmail.com
5*/
6
7#include "vector.h"
8#include "math.h"
9#include "gameengine.h" //used as reference
10#include "engine_utils.h"
11///////////////////////////////////////////////////////////
13{
14 float fresult = 0.0f;
16 vResult.x = (float)pow((v.x - x), 2);
17 vResult.y = (float)pow((v.y - y), 2);
18 vResult.z = (float)pow((v.z - z), 2);
20
21 return fresult;
22}
23///////////////////////////////////////////////////////////
25{
26 float fresult = 0.0f;
28 vResult.x = (float)pow((v.x - x), 2);
29 vResult.y = (float)pow((v.y - y), 2);
30 vResult.z = (float)pow((v.z - z), 2);
31 fresult = (vResult.x + vResult.y + vResult.z);
32
33 return fresult;
34}
35///////////////////////////////////////////////////////////
37{
38 float ff = _fc * (10.0f * GameEngine::fDt );
39 return (_v1 * ff) + (_v2 * (1.0f - ff));
40
41 //return (_v1 * _fc) + (_v2 * (1.0f - _fc));
42
43 // deprecated because it takes more time
44 //Vector v = (_v1 * _fc) + (_v2 * (1.0f - _fc));
45 //return v;
46}
47///////////////////////////////////////////////////////////
49{
50 return os << "(" << v.x << ", " << v.y << ", " << v.z << ")" ;
51}
52///////////////////////////////////////////////////////////
54{
55 return ((x < v.x) && (y < v.y) && (z < v.z));
56}
57///////////////////////////////////////////////////////////
59{
60 return ((x <= v.x) && (y <= v.y) && (z <= v.z));
61}
62///////////////////////////////////////////////////////////
64{
65 return ((x > v.x) && (y > v.y) && (z > v.z));
66}
67///////////////////////////////////////////////////////////
69{
70 return ((x >= v.x) && (y >= v.y) && (z >= v.z));
71}
72///////////////////////////////////////////////////////////
73// ImGui conversion implementations
74// Note: These are only usable when imgui.h is included in the translation unit
75#ifdef IMGUI_VERSION
76#include "third_party/imgui/imgui.h"
77
79{
80 return ImVec2(x, y);
81}
82
84{
85 return Vector(v.x, v.y, 0.0f);
86}
87#endif
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
static float fDt
Delta time between frames in seconds.
Definition GameEngine.h:120
float z
Definition vector.h:27
static Vector FromImVec2(const ImVec2 &v)
float y
Definition vector.h:27
float Dist(Vector &)
Definition vector.cpp:12
bool operator<(const Vector &v)
Definition vector.cpp:53
bool operator<=(const Vector &v)
Definition vector.cpp:58
float x
Definition vector.h:27
ImVec2 ToImVec2() const
bool operator>(const Vector &v)
Definition vector.cpp:63
Vector(void)
Definition vector.h:28
bool operator>=(const Vector &v)
Definition vector.cpp:68
float sqrDist(Vector &)
Definition vector.cpp:24
ostream & operator<<(ostream &os, const Vector &v)
Definition vector.cpp:48
Vector vBlend(Vector &_v1, Vector &_v2, float _fc)
Definition vector.cpp:36