perfect-shape 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +13 -4
- data/VERSION +1 -1
- data/lib/perfect_shape/line.rb +3 -2
- data/perfect-shape.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 934071723ece0f7ebe64e6e67880b5a1f4ec6781517d2ee2a7dea70ceae4a9be
|
4
|
+
data.tar.gz: d436da8745d7f4d971a7df04b5d54701e6e89abb9f8624273f79a6ac1d28ea77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcea5c4c02f2e056c0e18a857404bbef4b411420c2c3a7e438a2f122df90a30466979c60cc7804c61b5d454ed2879cd81fd1fc750360839393c20a4561aebce6
|
7
|
+
data.tar.gz: c321b5b1697b28e9608c11d4bc5e04038c3e269df311b9c7263e468c6f952c60bec6ecf4244ff044eb8fb33cf68462e9d362326962c0473bbd72150847181e0e
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.9
|
4
|
+
|
5
|
+
- `PerfectShape::Line#contain?(x_or_point, y=nil, distance: 0)` (add a distance tolerance fuzz factor option)
|
6
|
+
|
3
7
|
## 0.0.8
|
4
8
|
|
5
9
|
- `PerfectShape::Line`
|
6
|
-
- `PerfectShape::Line#contain
|
10
|
+
- `PerfectShape::Line#contain?(x_or_point, y=nil)`
|
7
11
|
- `PerfectShape::Line#relative_counterclockwise`
|
8
12
|
- `PerfectShape::Line#point_segment_distance`
|
9
13
|
- Update `PerfectShape::Math::radians_to_degrees`, `PerfectShape::Math::degrees_to_radians`, and `PerfectShape::Math::normalize_degrees` to normalize numbers to `BigDecimal`
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Perfect Shape 0.0.
|
1
|
+
# Perfect Shape 0.0.9
|
2
2
|
## Geometric Algorithms
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/perfect-shape.svg)](http://badge.fury.io/rb/perfect-shape)
|
4
4
|
|
@@ -13,13 +13,13 @@ To ensure high accuracy, this library does all its mathematical operations with
|
|
13
13
|
Run:
|
14
14
|
|
15
15
|
```
|
16
|
-
gem install perfect-shape -v 0.0.
|
16
|
+
gem install perfect-shape -v 0.0.9
|
17
17
|
```
|
18
18
|
|
19
19
|
Or include in Bundler `Gemfile`:
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
gem 'perfect-shape', '~> 0.0.
|
22
|
+
gem 'perfect-shape', '~> 0.0.9'
|
23
23
|
```
|
24
24
|
|
25
25
|
And, run:
|
@@ -74,6 +74,7 @@ Module
|
|
74
74
|
### `PerfectShape::Line`
|
75
75
|
|
76
76
|
Class
|
77
|
+
|
77
78
|
Extends `PerfectShape::Shape`
|
78
79
|
|
79
80
|
![line](images/line.png)
|
@@ -91,14 +92,16 @@ Extends `PerfectShape::Shape`
|
|
91
92
|
- `#center_x`: center x
|
92
93
|
- `#center_y`: center y
|
93
94
|
- `#bounding_box`: bounding box is a rectangle with x = min x, y = min y, and width/height of shape
|
94
|
-
- `#contain?(x_or_point, y=nil)`: checks if point lies on line
|
95
|
+
- `#contain?(x_or_point, y=nil, distance: 0)`: checks if point lies on line, with a distance tolerance (0 by default). Distance tolerance provides a fuzz factor that for example enables GUI users to mouse-click-select a line shape in a GUI more successfully.
|
95
96
|
- `#relative_counterclockwise(x_or_point, y=nil)`: Returns an indicator of where the specified point (px,py) lies with respect to the line segment from (x1,y1) to (x2,y2). The return value can be either 1, -1, or 0 and indicates in which direction the specified line must pivot around its first end point, (x1,y1), in order to point at the specified point (px,py). A return value of 1 indicates that the line segment must turn in the direction that takes the positive X axis towards the negative Y axis. In the default coordinate system used by Java 2D, this direction is counterclockwise. A return value of -1 indicates that the line segment must turn in the direction that takes the positive X axis towards the positive Y axis. In the default coordinate system, this direction is clockwise. A return value of 0 indicates that the point lies exactly on the line segment. Note that an indicator value of 0 is rare and not useful for determining collinearity because of floating point rounding issues. If the point is colinear with the line segment, but not between the end points, then the value will be -1 if the point lies “beyond (x1,y1)” or 1 if the point lies “beyond (x2,y2)”.
|
96
97
|
- `#point_segment_distance(x_or_point, y=nil)`: Returns the distance from a point to a line segment.
|
97
98
|
|
98
99
|
### `PerfectShape::Rectangle`
|
99
100
|
|
100
101
|
Class
|
102
|
+
|
101
103
|
Extends `PerfectShape::Shape`
|
104
|
+
|
102
105
|
Includes `PerfectShape::RectangularShape`
|
103
106
|
|
104
107
|
![rectangle](images/rectangle.png)
|
@@ -120,6 +123,7 @@ Includes `PerfectShape::RectangularShape`
|
|
120
123
|
### `PerfectShape::Square`
|
121
124
|
|
122
125
|
Class
|
126
|
+
|
123
127
|
Extends `PerfectShape::Rectangle`
|
124
128
|
|
125
129
|
![square](images/square.png)
|
@@ -142,7 +146,9 @@ Extends `PerfectShape::Rectangle`
|
|
142
146
|
### `PerfectShape::Arc`
|
143
147
|
|
144
148
|
Class
|
149
|
+
|
145
150
|
Extends `PerfectShape::Shape`
|
151
|
+
|
146
152
|
Includes `PerfectShape::RectangularShape`
|
147
153
|
|
148
154
|
Arcs can be of type `:open`, `:chord`, or `:pie`
|
@@ -173,6 +179,7 @@ Open Arc | Chord Arc | Pie Arc
|
|
173
179
|
### `PerfectShape::Ellipse`
|
174
180
|
|
175
181
|
Class
|
182
|
+
|
176
183
|
Extends `PerfectShape::Arc`
|
177
184
|
|
178
185
|
![ellipse](images/ellipse.png)
|
@@ -199,6 +206,7 @@ Extends `PerfectShape::Arc`
|
|
199
206
|
### `PerfectShape::Circle`
|
200
207
|
|
201
208
|
Class
|
209
|
+
|
202
210
|
Extends `PerfectShape::Ellipse`
|
203
211
|
|
204
212
|
![circle](images/circle.png)
|
@@ -227,6 +235,7 @@ Extends `PerfectShape::Ellipse`
|
|
227
235
|
### `PerfectShape::Polygon`
|
228
236
|
|
229
237
|
Class
|
238
|
+
|
230
239
|
Extends `PerfectShape::Shape`
|
231
240
|
|
232
241
|
![polygon](images/polygon.png)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.9
|
data/lib/perfect_shape/line.rb
CHANGED
@@ -195,11 +195,12 @@ module PerfectShape
|
|
195
195
|
# @return {@code true} if the point lies within the bound of
|
196
196
|
# the polygon, {@code false} if the point lies outside of the
|
197
197
|
# polygon's bounds.
|
198
|
-
def contain?(x_or_point, y = nil)
|
198
|
+
def contain?(x_or_point, y = nil, distance: 0)
|
199
199
|
x, y = normalize_point(x_or_point, y)
|
200
200
|
return unless x && y
|
201
|
+
distance = BigDecimal(distance.to_s)
|
201
202
|
# TODO implement contain?(point) with a fuzz factor to enable successfully selecting a line in a GUI application
|
202
|
-
Line.point_segment_distance(points[0][0], points[0][1], points[1][0], points[1][1], x, y)
|
203
|
+
Line.point_segment_distance(points[0][0], points[0][1], points[1][0], points[1][1], x, y) <= distance
|
203
204
|
end
|
204
205
|
|
205
206
|
def point_segment_distance(x_or_point, y = nil)
|
data/perfect-shape.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: perfect-shape 0.0.
|
5
|
+
# stub: perfect-shape 0.0.9 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "perfect-shape".freeze
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.9"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|