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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
//! Items related to the geometry that joins two lines together.
//!
//! Line joins describe the style of geometry used to fill the space at which two lines would
//! intersect. The following diagram shows the space occuppied by a line join between A and B.
//!
//!
//! ```ignore
//! Line join fills this space.
//! This one is a "miter" join.
//!
//! /
//! /
//! Line A /
//!
//! ^ ------------------------xxxx ^
//! | xxxxx | half_thickness
//! thickness | ------------------------xxxxxx v
//! | xxxx \
//! v ------------------------x \ \
//! \ \ \
//! \ \ \ Line B
//! \ \ \
//! \ \ \
//! \ \ \
//! ```
//!
//! Nannou provides three common types of line joins:
//!
//! - [**miter**](./miter/index.html): Extends the stroke to where the edges on each side bisect.
//! This is the default join type.
//! - [**round**](./round/index.html): Rounds the outside edge with a circle the diameter of the
//! thickness.
//! - [**bevel**](./bevel/index.html): Cuts the outside edge off where a circle the diameter of the
//! thickness intersects
use crate;
use crateBaseFloat;
/// Given three points that describe two lines and half the thickness of the line, return the two
/// points that intersect on either side of the line.
///
/// The following diagram describes the expected arguments as well as the left `L` and right `R`
/// fields of the tuple result.
///
/// ```ignore
/// ------------------------------- L ^
/// | half_thickness
/// a ------------------------------- b v
/// \
/// ------------------------------R \ \
/// \ \ \
/// Line 1 \ \ \
/// \ \ \
/// Line 2 \ \ \
/// \ \ \
///
/// c
/// ```
///
/// ## Example
///
/// ```
///
///
/// use nannou::prelude::*;
/// use nannou::geom::line;
///
/// fn main() {
/// // Find `L` and `R`.
/// //
/// // | c | ^
/// // | | | |
/// // | | | | 2.0
/// // --------L | | |
/// // | | |
/// // a----------b | v
/// // |
/// // --------------R
/// //
/// // <---------->
/// // 2.0
///
/// let a = pt2(0.0, 0.0);
/// let b = pt2(2.0, 0.0);
/// let c = pt2(2.0, 2.0);
/// let half_thickness = 1.0;
/// let result = line::join::intersections(a, b, c, half_thickness);
/// assert_eq!(Some((pt2(1.0, 1.0), pt2(3.0, -1.0))), result);
/// }
/// ```
/// The point of intersection between two straight lines.
///
/// Returns `None` if the two lines are parallel.
///
/// ```ignore
///
/// b
///
/// \
/// \
/// \
/// a -------------------X------------------ a
/// \
/// \
/// \
/// \
/// \
/// \
/// \
/// \
///
/// b
///
/// ```
///
/// ## Example
///
/// ```
///
///
/// use nannou::prelude::*;
/// use nannou::geom::line;
///
/// fn main() {
/// let a = (pt2(4.0, 0.0), pt2(6.0, 10.0));
/// let b = (pt2(0.0, 3.0), pt2(10.0, 7.0));
/// assert_eq!(Some(pt2(5.0, 5.0)), line::join::intersect(a, b));
///
/// let a = (pt2(0.0, 1.0), pt2(3.0, 1.0));
/// let b = (pt2(2.0, 2.0), pt2(4.0, 2.0));
/// assert_eq!(None, line::join::intersect(a, b));
///
/// let a = (pt2(0.0, 0.0), pt2(2.0, 2.0));
/// let b = (pt2(0.0, 10.0), pt2(10.0, 0.0));
/// assert_eq!(Some(pt2(5.0, 5.0)), line::join::intersect(a, b));
/// assert_ne!(Some(pt2(4.9, 5.1)), line::join::intersect(a, b));
/// }
/// ```