Skip to content

Commit

Permalink
adjusted corner orientation to be solved with Y axis
Browse files Browse the repository at this point in the history
  • Loading branch information
Odilf committed Aug 12, 2023
1 parent e1d28bc commit 3b5a505
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion barbarosa/src/cube_n/cube3/mus/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ fn adjust_second_edges_for_indexing(edges: &HalfEdgesMUS) -> HalfEdgesMUS {
let mut output = edges.clone();

for edge in output.iter_mut() {
// edge.slice_position = -edge.slice_position;
edge.rotate(&AxisRotation::new(Axis::X, Amount::Double))
}

Expand Down
13 changes: 8 additions & 5 deletions barbarosa/src/cube_n/pieces/corner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,14 @@ impl Corner {
}
}

/// The axis that is considered to be the correct orientation axis for corners
pub const ORIENTED_AXIS: Axis = Axis::Y;

/// Creates a new [Corner] with the given position and correct orientation.
pub const fn oriented(position: Vec3) -> Self {
Self {
position,
orientation_axis: Axis::X,
orientation_axis: Self::ORIENTED_AXIS,
}
}

Expand All @@ -117,12 +120,12 @@ impl Corner {
// TODO: Check the "i think" part
pub fn orientation_index(&self) -> usize {
let even_parity = Self::is_even_position_parity(&self.position);
let axis_index = self.orientation_axis as usize;
let axis_index = self.orientation_axis as i32;

if even_parity {
axis_index
(axis_index - 1).rem_euclid(3) as usize
} else {
(3 - axis_index).rem_euclid(3)
(1 - axis_index).rem_euclid(3) as usize
}
}

Expand Down Expand Up @@ -150,7 +153,7 @@ impl Corner {
///
/// This method might be ever so slightly faster then doing `corner.orientation_index() == 0`.
pub fn is_oriented(&self) -> bool {
self.orientation_axis == Axis::X
self.orientation_axis == Self::ORIENTED_AXIS
}
}

Expand Down
7 changes: 2 additions & 5 deletions barbarosa/src/cube_n/visualization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ use crate::{cube3::Cube3, generic::Piece};

use self::unfolded::Unfolded;

use super::{
space::{Axis, Face},
Corner, Edge,
};
use super::{space::Face, Corner, Edge};

mod test;
pub mod unfolded;
Expand Down Expand Up @@ -87,7 +84,7 @@ impl fmt::Debug for Color {
impl Colored for Corner {
fn colors(&self, original_pos: Self::Position) -> Vec<(Face, Color)> {
let mut current_axis = self.orientation_axis;
let mut original_axis = Axis::X;
let mut original_axis = Corner::ORIENTED_AXIS;

let mut output = Vec::with_capacity(3);

Expand Down

0 comments on commit 3b5a505

Please sign in to comment.