[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src vector.cxx,1.1,1.2 vector.hxx,1.1,1.2
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src vector.cxx,1.1,1.2 vector.hxx,1.1,1.2 |
Date: |
15 Oct 2002 19:13:35 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv29772
Modified Files:
vector.cxx vector.hxx
Log Message:
cleaned up worldmap code a bit, interupting the walk and reverse half the way
down works now
Index: vector.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/vector.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- vector.cxx 28 Sep 2002 11:52:22 -0000 1.1
+++ vector.cxx 15 Oct 2002 19:13:32 -0000 1.2
@@ -126,6 +126,32 @@
);
}
+float
+Vector::distance(const Vector& a, const Vector& b)
+{
+ float x = b.x - a.x;
+ float y = b.y - a.y;
+ float z = b.z - a.z;
+
+ return fabsf(sqrt((x * x) + (y * y) + (z * z)));
+}
+
+float
+Vector::distance2d(const Vector& a, const Vector& b)
+{
+ float x = b.x - a.x;
+ float y = b.y - a.y;
+
+ return fabsf(sqrt((x * x) + (y * y)));
+}
+
+Vector
+Vector::interpolate(const Vector& a, const Vector& b, float perc)
+{
+ Vector c = b - a;
+ return a + (c * perc);
+}
+
std::ostream& operator<< (std::ostream& os, const Vector& v)
{
return os << v.x << " " << v.y << " " << v.z;
Index: vector.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/vector.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- vector.hxx 28 Sep 2002 11:52:22 -0000 1.1
+++ vector.hxx 15 Oct 2002 19:13:32 -0000 1.2
@@ -50,6 +50,13 @@
Vector rotate (float angle, const Vector& pos) const;
+ static float distance(const Vector& a, const Vector& b);
+ static float distance2d(const Vector& a, const Vector& b);
+
+ /** Calculate a position between a and b, relative to the value of
+ \a perc (perc == 0 -> a, perc == 1.0 -> b) */
+ static Vector interpolate(const Vector& a, const Vector& b, float perc);
+
friend std::ostream& operator<< (std::ostream& os, const Vector& v);
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src vector.cxx,1.1,1.2 vector.hxx,1.1,1.2,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldmap path_graph.cxx,1.10,1.11 pathfinder.hxx,1.5,1.6
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldmap path.cxx,NONE,1.1 path.hxx,NONE,1.1 Makefile.am,1.10,1.11 path_graph.cxx,1.11,1.12 path_graph.hxx,1.5,1.6 pathfinder.hxx,1.6,1.7 pingus.cxx,1.17,1.18 pingus.hxx,1.17,1.18
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldmap path_graph.cxx,1.10,1.11 pathfinder.hxx,1.5,1.6
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldmap path.cxx,NONE,1.1 path.hxx,NONE,1.1 Makefile.am,1.10,1.11 path_graph.cxx,1.11,1.12 path_graph.hxx,1.5,1.6 pathfinder.hxx,1.6,1.7 pingus.cxx,1.17,1.18 pingus.hxx,1.17,1.18
- Index(es):