Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nicklockwood / Euclid / 85

25 Nov 2019 - 22:48 coverage: 59.746% (+0.3%) from 59.414%
85

Pull #10

travis-ci

9181eb84f9c35729a3bad740fb7f9d93?size=18&default=identiconweb-flow
Make a LineSegment struct and add public initializers
Pull Request #10: Planes and angles

26 of 42 new or added lines in 3 files covered. (61.9%)

1269 of 2124 relevant lines covered (59.75%)

940.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

20.0
/Sources/Line.swift
1
//
2
//  Line.swift
3
//  Euclid
4
//
5
//  Created by Nick Lockwood on 20/11/2019.
6
//  Copyright © 2018 Nick Lockwood. All rights reserved.
7
//
8
//  Distributed under the permissive MIT license
9
//  Get the latest version from here:
10
//
11
//  https://github.com/nicklockwood/Euclid
12
//
13
//  Permission is hereby granted, free of charge, to any person obtaining a copy
14
//  of this software and associated documentation files (the "Software"), to deal
15
//  in the Software without restriction, including without limitation the rights
16
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
//  copies of the Software, and to permit persons to whom the Software is
18
//  furnished to do so, subject to the following conditions:
19
//
20
//  The above copyright notice and this permission notice shall be included in all
21
//  copies or substantial portions of the Software.
22
//
23
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
//  SOFTWARE.
30
//
31

32
import Foundation
33

34
public struct LineSegment : Hashable {
NEW
35
    public init(point1: Vector, point2: Vector) {
!
NEW
36
        self.point1 = point1
!
NEW
37
        self.point2 = point2
!
NEW
38
    }
!
39
    
40
    public var point1: Vector {
NEW
41
        didSet { point1 = point1.quantized() }
!
42
    }
43
    
44
    public var point2: Vector {
NEW
45
        didSet { point2 = point2.quantized() }
!
46
    }
47
    
NEW
48
    public var direction : Vector {
!
NEW
49
        let diff = point2 - point1
!
NEW
50
        return diff.normalized()
!
NEW
51
    }
!
52
}
53

54
public struct Line : Hashable {
55
    public init(point: Vector, direction: Vector) {
2×
56
        self.point = point
2×
57
        self.direction = direction
2×
58
    }
2×
59
    
NEW
60
    public init(from: LineSegment) {
!
NEW
61
        self.point = from.point1
!
NEW
62
        self.direction = from.direction
!
NEW
63
    }
!
64
    
65
    public var point: Vector {
NEW
66
        didSet { point = point.quantized() }
!
67
    }
68

69
    public var direction: Vector {
NEW
70
        didSet { direction = direction.normalized() }
!
71
    }
72
}
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2023 Coveralls, Inc