rotate to face: use trafo matrix

This commit is contained in:
Michael Kirsch 2019-05-26 19:51:34 +02:00 committed by Joseph Lenox
parent 63ac0a1d0c
commit c689eb47bd

View File

@ -1634,23 +1634,21 @@ sub rotate_face {
return if !defined $normal; return if !defined $normal;
my $axis = $dlg->SelectedAxis; my $axis = $dlg->SelectedAxis;
return if !defined $axis; return if !defined $axis;
# Actual math to rotate my $axis_vec = Slic3r::Pointf3->new(0,0,0);
my $angleToXZ = atan2($normal->y(),$normal->x());
my $angleToZ = acos(-$normal->z());
$self->rotate(-rad2deg($angleToXZ),Z);
$self->rotate(rad2deg($angleToZ),Y);
if($axis == Z){ if($axis == Z){
$self->add_undo_operation("GROUP", $object->identifier, splice(@{$self->{undo_stack}},-2)); $axis_vec->set_z(1);
} else { } else {
if($axis == X){ if($axis == X){
$self->rotate(90,Y); $axis_vec->set_x(1);
} else { } else {
$self->rotate(90,X); $axis_vec->set_y(1);
} }
$self->add_undo_operation("GROUP", $object->identifier, splice(@{$self->{undo_stack}},-3));
} }
$object->rotate_vec_to_vec($normal,$axis_vec);
#TODO: undo stack
} }
sub rotate { sub rotate {