Browse Source

Start fixing vertex order

master
Georg Hopp 6 years ago
parent
commit
e5a7533fad
Signed by: ghopp GPG Key ID: 4C5D226768784538
  1. 21
      fractional/src/easel.rs
  2. 5
      fractional/src/main.rs

21
fractional/src/easel.rs

@ -275,7 +275,7 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T>
+ Debug + Copy + From<i32> {
fn new(p :&'a Polygon<T>, direction :Direction) -> Self {
let top = p.vert_min();
let top = p.vert_min(direction);
let next = p.next_y(top, direction);
let edge = match next {
None => None,
@ -330,7 +330,7 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T>
impl<T> Polygon<T>
where T: Add<Output = T> + Sub<Output = T> + Div<Output = T>
+ Copy + Debug + From<i32> {
fn vert_min<'a>(&'a self) -> usize {
fn vert_min<'a>(&'a self, d :Direction) -> usize {
let Polygon(Coordinates(cs)) = self;
type ICoord<'a,T> = (usize, &'a Coordinate<T>);
@ -341,7 +341,12 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T>
Some(a) => {
let Coordinate(_, ay, _) = a.1;
let Coordinate(_, xy, _) = x.1;
if xy < ay {Some(x)} else {Some(a)}
match d {
Direction::Left =>
if xy < ay {Some(x)} else {Some(a)},
Direction::Right =>
if xy <= ay {Some(x)} else {Some(a)},
}
},
};
@ -401,6 +406,16 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T>
cmp::Ordering::Less => None,
// TODO On equal we need to find out which one of both to
// keep in the list… (the outermost)
// But how can we find the outermost...
// I think it depends on the previous and next one
// which means this might not be best suited for
// a recursive approach...we could keep both...
// Anyway, it looks like this is only a problem
// for the first vertex so maybe it is enough
// to choose the correct one when starting which
// would be in the vert_min method.
// Well, after adding some logic to vert_min it
// seems it is also relevant for the last one.
cmp::Ordering::Equal => inner(p, c, p.step(n, d), d),
cmp::Ordering::Greater => Some(n),
}

5
fractional/src/main.rs

@ -342,8 +342,9 @@ fn _democanvas<T>( xcb :&XcbEasel
let rot1 = TMatrix::combine(vec!(rz, rx, t));
let rot2 = TMatrix::combine(vec!(rz, ry, t));
let objects = vec!( (tetrahedron.transform(&rot1), 0xFFFF00)
, ( cube.transform(&rot2), 0x0000FF) );
let objects = vec!( (tetrahedron.transform(&rot1), 0xFFFF00) );
//let objects = vec!( (tetrahedron.transform(&rot1), 0xFFFF00)
// , ( cube.transform(&rot2), 0x0000FF) );
//let objects = vec!( (triangle.transform(&rot1), 0xFFFF00) );
<XcbCanvas as Canvas<T>>::clear(&mut canvas);

Loading…
Cancel
Save