Showing
2 changed files
with
21 additions
and
5 deletions
| @@ -275,7 +275,7 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T> | @@ -275,7 +275,7 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T> | ||
| 275 | + Debug + Copy + From<i32> { | 275 | + Debug + Copy + From<i32> { |
| 276 | 276 | ||
| 277 | fn new(p :&'a Polygon<T>, direction :Direction) -> Self { | 277 | fn new(p :&'a Polygon<T>, direction :Direction) -> Self { |
| 278 | - let top = p.vert_min(); | 278 | + let top = p.vert_min(direction); |
| 279 | let next = p.next_y(top, direction); | 279 | let next = p.next_y(top, direction); |
| 280 | let edge = match next { | 280 | let edge = match next { |
| 281 | None => None, | 281 | None => None, |
| @@ -330,7 +330,7 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T> | @@ -330,7 +330,7 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T> | ||
| 330 | impl<T> Polygon<T> | 330 | impl<T> Polygon<T> |
| 331 | where T: Add<Output = T> + Sub<Output = T> + Div<Output = T> | 331 | where T: Add<Output = T> + Sub<Output = T> + Div<Output = T> |
| 332 | + Copy + Debug + From<i32> { | 332 | + Copy + Debug + From<i32> { |
| 333 | - fn vert_min<'a>(&'a self) -> usize { | 333 | + fn vert_min<'a>(&'a self, d :Direction) -> usize { |
| 334 | let Polygon(Coordinates(cs)) = self; | 334 | let Polygon(Coordinates(cs)) = self; |
| 335 | 335 | ||
| 336 | type ICoord<'a,T> = (usize, &'a Coordinate<T>); | 336 | type ICoord<'a,T> = (usize, &'a Coordinate<T>); |
| @@ -341,7 +341,12 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T> | @@ -341,7 +341,12 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T> | ||
| 341 | Some(a) => { | 341 | Some(a) => { |
| 342 | let Coordinate(_, ay, _) = a.1; | 342 | let Coordinate(_, ay, _) = a.1; |
| 343 | let Coordinate(_, xy, _) = x.1; | 343 | let Coordinate(_, xy, _) = x.1; |
| 344 | - if xy < ay {Some(x)} else {Some(a)} | 344 | + match d { |
| 345 | + Direction::Left => | ||
| 346 | + if xy < ay {Some(x)} else {Some(a)}, | ||
| 347 | + Direction::Right => | ||
| 348 | + if xy <= ay {Some(x)} else {Some(a)}, | ||
| 349 | + } | ||
| 345 | }, | 350 | }, |
| 346 | }; | 351 | }; |
| 347 | 352 | ||
| @@ -401,6 +406,16 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T> | @@ -401,6 +406,16 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T> | ||
| 401 | cmp::Ordering::Less => None, | 406 | cmp::Ordering::Less => None, |
| 402 | // TODO On equal we need to find out which one of both to | 407 | // TODO On equal we need to find out which one of both to |
| 403 | // keep in the list… (the outermost) | 408 | // keep in the list… (the outermost) |
| 409 | + // But how can we find the outermost... | ||
| 410 | + // I think it depends on the previous and next one | ||
| 411 | + // which means this might not be best suited for | ||
| 412 | + // a recursive approach...we could keep both... | ||
| 413 | + // Anyway, it looks like this is only a problem | ||
| 414 | + // for the first vertex so maybe it is enough | ||
| 415 | + // to choose the correct one when starting which | ||
| 416 | + // would be in the vert_min method. | ||
| 417 | + // Well, after adding some logic to vert_min it | ||
| 418 | + // seems it is also relevant for the last one. | ||
| 404 | cmp::Ordering::Equal => inner(p, c, p.step(n, d), d), | 419 | cmp::Ordering::Equal => inner(p, c, p.step(n, d), d), |
| 405 | cmp::Ordering::Greater => Some(n), | 420 | cmp::Ordering::Greater => Some(n), |
| 406 | } | 421 | } |
| @@ -342,8 +342,9 @@ fn _democanvas<T>( xcb :&XcbEasel | @@ -342,8 +342,9 @@ fn _democanvas<T>( xcb :&XcbEasel | ||
| 342 | let rot1 = TMatrix::combine(vec!(rz, rx, t)); | 342 | let rot1 = TMatrix::combine(vec!(rz, rx, t)); |
| 343 | let rot2 = TMatrix::combine(vec!(rz, ry, t)); | 343 | let rot2 = TMatrix::combine(vec!(rz, ry, t)); |
| 344 | 344 | ||
| 345 | - let objects = vec!( (tetrahedron.transform(&rot1), 0xFFFF00) | ||
| 346 | - , ( cube.transform(&rot2), 0x0000FF) ); | 345 | + let objects = vec!( (tetrahedron.transform(&rot1), 0xFFFF00) ); |
| 346 | + //let objects = vec!( (tetrahedron.transform(&rot1), 0xFFFF00) | ||
| 347 | + // , ( cube.transform(&rot2), 0x0000FF) ); | ||
| 347 | //let objects = vec!( (triangle.transform(&rot1), 0xFFFF00) ); | 348 | //let objects = vec!( (triangle.transform(&rot1), 0xFFFF00) ); |
| 348 | 349 | ||
| 349 | <XcbCanvas as Canvas<T>>::clear(&mut canvas); | 350 | <XcbCanvas as Canvas<T>>::clear(&mut canvas); |
Please
register
or
login
to post a comment