Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Point.pm « Slic3r « lib - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 233f60f34a5d572b790b5d96e07ed6195be6dd11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package Slic3r::Point;
use strict;
use warnings;

use Storable qw();

sub new {
    my $class = shift;
    my $self;
    if (@_ == 2) {
        $self = [@_];
    } elsif ((ref $_[0]) =~ 'ARRAY' || (ref $_[0]) =~ /Slic3r::Point/) {
        $self = [@{$_[0]}];
    } elsif ($_[0]->isa(__PACKAGE__)) {
        return $_[0];
    } else {
        die "Invalid arguments for ${class}->new";
    }
    bless $self, $class;
    return $self;
}

sub clone {
    Storable::dclone($_[0])
}

sub coincides_with {
    my $self = shift;
    my ($point) = @_;
    return Slic3r::Geometry::points_coincide($self, $point);
}

sub distance_to {
    my $self = shift;
    my ($point) = @_;
    return Slic3r::Geometry::distance_between_points($self, $point);
}

sub scale {
    my $self = shift;
    my ($factor) = @_;
    $_ *= $factor for @$self;
    $self;
}

sub rotate {
    my $self = shift;
    my ($angle, $center) = @_;
    @$self = @{ +(Slic3r::Geometry::rotate_points($angle, $center, $self))[0] };
    $self;
}

sub translate {
    my $self = shift;
    my ($x, $y) = @_;
    @$self = @{ +(Slic3r::Geometry::move_points([$x, $y], $self))[0] };
    $self;
}

sub x { $_[0]->[0] }
sub y { $_[0]->[1] }

1;