~ubuntu-branches/ubuntu/utopic/slic3r/utopic

« back to all changes in this revision

Viewing changes to t/angles.t

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2014-06-17 01:27:26 UTC
  • Revision ID: package-import@ubuntu.com-20140617012726-2wrs4zdo251nr4vg
Tags: upstream-1.1.4+dfsg
Import upstream version 1.1.4+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use Test::More;
 
2
use strict;
 
3
use warnings;
 
4
 
 
5
plan tests => 26;
 
6
 
 
7
BEGIN {
 
8
    use FindBin;
 
9
    use lib "$FindBin::Bin/../lib";
 
10
}
 
11
 
 
12
use Slic3r;
 
13
use Slic3r::Geometry qw(rad2deg_dir angle3points PI);
 
14
 
 
15
#==========================================================
 
16
 
 
17
{
 
18
    is line_atan([ [0, 0],  [10, 0] ]),  (0),      'E atan2';
 
19
    is line_atan([ [10, 0], [0, 0]  ]),  (PI),     'W atan2';
 
20
    is line_atan([ [0, 0],  [0, 10] ]),  (PI/2),   'N atan2';
 
21
    is line_atan([ [0, 10], [0, 0]  ]), -(PI/2),   'S atan2';
 
22
    
 
23
    is line_atan([ [10, 10], [0, 0] ]), -(PI*3/4), 'SW atan2';
 
24
    is line_atan([ [0, 0], [10, 10] ]),  (PI*1/4), 'NE atan2';
 
25
    is line_atan([ [0, 10], [10, 0] ]), -(PI*1/4), 'SE atan2';
 
26
    is line_atan([ [10, 0], [0, 10] ]),  (PI*3/4), 'NW atan2';
 
27
}
 
28
 
 
29
#==========================================================
 
30
 
 
31
{
 
32
    is line_direction([ [0, 0],  [10, 0] ]), (0),      'E direction';
 
33
    is line_direction([ [10, 0], [0, 0]  ]), (0),      'W direction';
 
34
    is line_direction([ [0, 0],  [0, 10] ]), (PI/2),   'N direction';
 
35
    is line_direction([ [0, 10], [0, 0]  ]), (PI/2),   'S direction';
 
36
    
 
37
    is line_direction([ [10, 10], [0, 0] ]), (PI*1/4), 'SW direction';
 
38
    is line_direction([ [0, 0], [10, 10] ]), (PI*1/4), 'NE direction';
 
39
    is line_direction([ [0, 10], [10, 0] ]), (PI*3/4), 'SE direction';
 
40
    is line_direction([ [10, 0], [0, 10] ]), (PI*3/4), 'NW direction';
 
41
}
 
42
 
 
43
#==========================================================
 
44
 
 
45
{
 
46
    is rad2deg_dir(0),        90, 'E (degrees)';
 
47
    is rad2deg_dir(PI),      270, 'W (degrees)';
 
48
    is rad2deg_dir(PI/2),      0, 'N (degrees)';
 
49
    is rad2deg_dir(-(PI/2)), 180, 'S (degrees)';
 
50
    is rad2deg_dir(PI*1/4),   45, 'NE (degrees)';
 
51
    is rad2deg_dir(PI*3/4),  135, 'NW (degrees)';
 
52
    is rad2deg_dir(PI/6),     60, '30°';
 
53
    is rad2deg_dir(PI/6*2),   30, '60°';
 
54
}
 
55
 
 
56
#==========================================================
 
57
 
 
58
{
 
59
    is angle3points([0,0], [10,0], [0,10]), PI/2, 'CW angle3points';
 
60
    is angle3points([0,0], [0,10], [10,0]), PI/2*3, 'CCW angle3points';
 
61
}
 
62
 
 
63
#==========================================================
 
64
 
 
65
sub line_atan {
 
66
    my ($l) = @_;
 
67
    return Slic3r::Line->new(@$l)->atan2_;
 
68
}
 
69
 
 
70
sub line_direction {
 
71
    my ($l) = @_;
 
72
    return Slic3r::Line->new(@$l)->direction;
 
73
}
 
 
b'\\ No newline at end of file'