3 This file is part of R²C²
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
16 void Profile::append_point(const Point &p)
26 min_coords.x = min(min_coords.x, p.x);
27 min_coords.y = min(min_coords.y, p.y);
28 max_coords.x = max(max_coords.x, p.x);
29 max_coords.y = max(max_coords.y, p.y);
33 const Point &Profile::get_point(unsigned i) const
36 throw InvalidParameterValue("Index out of range");
40 Point Profile::get_edge_normal(unsigned i) const
42 if(i+1>=points.size())
43 throw InvalidParameterValue("Index out of range");
44 float dx = points[i+1].x-points[i].x;
45 float dy = points[i+1].y-points[i].y;
46 float len = sqrt(dx*dx+dy*dy);
47 return Point(dy/len, -dx/len);
51 Profile::Loader::Loader(Profile &p):
52 DataFile::ObjectLoader<Profile>(p)
54 add("point", &Loader::point);
57 void Profile::Loader::point(float x, float y)
59 obj.append_point(Point(x/1000, y/1000));