]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/track.cpp
Rename Point to Vector
[r2c2.git] / source / libr2c2 / track.cpp
index c6c1751d7b2388cdadeb78e9824a1fcb6fb544b5..0d4052ea999a83b6394bb79f7d03f9216604fc39 100644 (file)
@@ -65,7 +65,7 @@ Block &Track::get_block() const
        return *block;
 }
 
-void Track::set_position(const Point &p)
+void Track::set_position(const Vector &p)
 {
        pos = p;
 }
@@ -99,8 +99,8 @@ void Track::check_slope()
 
        if(links[0] && links[1])
        {
-               Point epp0 = links[0]->get_endpoint_position(links[0]->get_endpoint_by_link(*this));
-               Point epp1 = links[1]->get_endpoint_position(links[1]->get_endpoint_by_link(*this));
+               Vector epp0 = links[0]->get_endpoint_position(links[0]->get_endpoint_by_link(*this));
+               Vector epp1 = links[1]->get_endpoint_position(links[1]->get_endpoint_by_link(*this));
                pos.z = epp0.z;
                slope = epp1.z-pos.z;
        }
@@ -109,12 +109,12 @@ void Track::check_slope()
                slope = 0;
                if(links[0])
                {
-                       Point epp = links[0]->get_endpoint_position(links[0]->get_endpoint_by_link(*this));
+                       Vector epp = links[0]->get_endpoint_position(links[0]->get_endpoint_by_link(*this));
                        pos.z = epp.z;
                }
                else if(links[1])
                {
-                       Point epp = links[1]->get_endpoint_position(links[1]->get_endpoint_by_link(*this));
+                       Vector epp = links[1]->get_endpoint_position(links[1]->get_endpoint_by_link(*this));
                        pos.z = epp.z;
                }
        }
@@ -162,7 +162,7 @@ int Track::get_endpoint_by_link(Track &other) const
        return -1;
 }
 
-Point Track::get_endpoint_position(unsigned epi) const
+Vector Track::get_endpoint_position(unsigned epi) const
 {
        const vector<TrackType::Endpoint> &eps = type.get_endpoints();
        if(epi>=eps.size())
@@ -173,7 +173,7 @@ Point Track::get_endpoint_position(unsigned epi) const
        float c = cos(rot);
        float s = sin(rot);
 
-       Point p(pos.x+c*ep.pos.x-s*ep.pos.y, pos.y+s*ep.pos.x+c*ep.pos.y, pos.z);
+       Vector p(pos.x+c*ep.pos.x-s*ep.pos.y, pos.y+s*ep.pos.x+c*ep.pos.y, pos.z);
        if(eps.size()==2 && epi==1)
                p.z += slope;
        return p;
@@ -205,14 +205,14 @@ bool Track::snap_to(Track &other, bool link, float limit)
 
        for(unsigned i=0; i<eps.size(); ++i)
        {
-               Point epp = get_endpoint_position(i);
+               Vector epp = get_endpoint_position(i);
 
                for(unsigned j=0; j<other_eps.size(); ++j)
                {
                        if(other.get_link(j))
                                continue;
 
-                       Point epp2 = other.get_endpoint_position(j);
+                       Vector epp2 = other.get_endpoint_position(j);
                        float dx = epp2.x-epp.x;
                        float dy = epp2.y-epp.y;
                        float dz = epp2.z-epp.z;
@@ -221,7 +221,7 @@ bool Track::snap_to(Track &other, bool link, float limit)
                                if(!link || (!flex && !other.get_flex()))
                                {
                                        set_rotation(other.rot+other_eps[j].dir-eps[i].dir+M_PI);
-                                       Point p(epp2.x-(eps[i].pos.x*cos(rot)-eps[i].pos.y*sin(rot)),
+                                       Vector p(epp2.x-(eps[i].pos.x*cos(rot)-eps[i].pos.y*sin(rot)),
                                                epp2.y-(eps[i].pos.y*cos(rot)+eps[i].pos.x*sin(rot)),
                                                epp2.z);
                                        if(eps.size()==2 && i==1)
@@ -249,13 +249,13 @@ bool Track::snap_to(Track &other, bool link, float limit)
        return false;
 }
 
-bool Track::snap(Point &pt, float &d) const
+bool Track::snap(Vector &pt, float &d) const
 {
        const vector<TrackType::Endpoint> &eps = type.get_endpoints();
 
        for(unsigned i=0; i<eps.size(); ++i)
        {
-               Point epp = get_endpoint_position(i);
+               Vector epp = get_endpoint_position(i);
                float dx = pt.x-epp.x;
                float dy = pt.y-epp.y;
                if(dx*dx+dy*dy<1e-4)
@@ -307,7 +307,7 @@ TrackPoint Track::get_point(unsigned epi, unsigned path, float d) const
        float c = cos(rot);
        float s = sin(rot);
 
-       p.pos = Point(pos.x+c*p.pos.x-s*p.pos.y, pos.y+s*p.pos.x+c*p.pos.y, pos.z);
+       p.pos = Vector(pos.x+c*p.pos.x-s*p.pos.y, pos.y+s*p.pos.x+c*p.pos.y, pos.z);
        p.dir += rot;
        if(type.get_endpoints().size()==2)
        {
@@ -372,7 +372,7 @@ Track::Loader::Loader(Track &t):
 
 void Track::Loader::position(float x, float y, float z)
 {
-       obj.pos = Point(x, y, z);
+       obj.pos = Vector(x, y, z);
 }
 
 void Track::Loader::sensor_id(unsigned id)