remove to_vec from Pt2D; only need it in one triangulation-specific place

This commit is contained in:
Dustin Carlino 2018-09-18 13:42:34 -07:00
parent 49ebe97c21
commit e8ef4545fb
4 changed files with 5 additions and 13 deletions

View File

@ -98,8 +98,6 @@ impl<'a> GfxCtx<'a> {
);
}
// TODO triangulate the points here, or remove this and just have a version that draws
// triangles
pub fn draw_polygon(&mut self, color: Color, poly: &geom::Polygon) {
for pts in poly.for_drawing().iter() {
graphics::Polygon::new(color).draw(

View File

@ -88,7 +88,7 @@ impl Polygon {
pub fn for_drawing(&self) -> Vec<Vec<Vec2d>> {
self.triangles
.iter()
.map(|tri| vec![tri.pt1.to_vec(), tri.pt2.to_vec(), tri.pt3.to_vec()])
.map(|tri| vec![to_vec(tri.pt1), to_vec(tri.pt2), to_vec(tri.pt3)])
.collect()
}
@ -170,3 +170,7 @@ fn is_clockwise_polygon(pts: &Vec<Pt2D>) -> bool {
}
sum > 0.0
}
fn to_vec(pt: Pt2D) -> Vec2d {
[pt.x(), pt.y()]
}

View File

@ -1,4 +1,3 @@
use graphics::math::Vec2d;
use ordered_float::NotNaN;
use std::f64;
use std::fmt;
@ -54,11 +53,6 @@ impl Pt2D {
self.y
}
// TODO probably remove this
pub fn to_vec(&self) -> Vec2d {
[self.x(), self.y()]
}
// TODO better name
// TODO Meters for dist?
pub fn project_away(&self, dist: f64, theta: Angle) -> Pt2D {

View File

@ -71,7 +71,3 @@ pub fn regular_polygon(center: Pt2D, sides: usize, length: f64) -> Polygon {
pts.push(first_pt);
Polygon::new(&pts)
}
pub fn drawing_line(l: &Line) -> [f64; 4] {
[l.pt1().x(), l.pt1().y(), l.pt2().x(), l.pt2().y()]
}