geometric_trans 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +16 -0
- data/lib/geometric_trans.rb +38 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 279d3aa4316d7dc4faaeaf8bb0746308230c3ef8fffda9bf691c588778a0e9a0
|
4
|
+
data.tar.gz: fefc6bb9c1a348be93917b6ae1d38d22f109c722e5653840c2b66253bc19c369
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b842ed7747d800e3b9551526289953e48b17af43d020309c30b1995ca15e319682ee9dc2ced0293ce29c5dd36799150f0c9335ac3b623e0c69fa398ae43e8457
|
7
|
+
data.tar.gz: f5e85d7831a4f57b89f1c6245a71b0fce952e697fdac29bac09b7fac72d5b0a59a4786b3c07371fbb91edd380d02b403652c2466abc857c762146c0934fb9410
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Geometric_trans
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/geometric_trans)
|
4
|
+
|
5
|
+
Geometric_trans is a library for geometric transform in Ruby with minimal effort:
|
6
|
+
```ruby
|
7
|
+
require 'geometric_trans'
|
8
|
+
circles = [ {"radius" => 2, "x" => -6, "y" => 8}, {"radius" => 4, "x" => 10, "y" => 2} ]
|
9
|
+
Geometric_trans.find_rectangle_for_circles(circles)
|
10
|
+
# => {xMin: -8, yMin: -2, xMax: 14, yMax: 10}
|
11
|
+
```
|
12
|
+
### Install the gem
|
13
|
+
|
14
|
+
```sh
|
15
|
+
$ gem install geometric_trans
|
16
|
+
```
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Geometric_trans
|
2
|
+
|
3
|
+
def self.find_rectangle_for_circles (circles)
|
4
|
+
|
5
|
+
circlesSize = circles.size
|
6
|
+
|
7
|
+
#default
|
8
|
+
radius = circles.first["radius"]
|
9
|
+
x, y = circles.first.values_at("x", "y")
|
10
|
+
|
11
|
+
xMax = x + radius
|
12
|
+
xMin = x - radius
|
13
|
+
yMax = y + radius
|
14
|
+
yMin = y - radius
|
15
|
+
|
16
|
+
if circlesSize > 1
|
17
|
+
circles[1..circlesSize].each do |circle|
|
18
|
+
|
19
|
+
radius = circle["radius"]
|
20
|
+
x,y = circle.values_at("x", "y")
|
21
|
+
varXMax = x + radius
|
22
|
+
varXMin = x - radius
|
23
|
+
varYMax = y + radius
|
24
|
+
varYMin = y - radius
|
25
|
+
|
26
|
+
xMax = varXMax if varXMax > xMax
|
27
|
+
xMin = varXMin if varXMin < xMin
|
28
|
+
yMax = varYMax if varYMax > yMax
|
29
|
+
yMin = varYMin if varYMin < yMin
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
{ xMin: xMin, yMin: yMin, xMax: xMax, yMax: yMax }
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: geometric_trans
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bondarenko Sergei
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Methods for geometric transformations
|
14
|
+
email: skino.yes@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- README.md
|
20
|
+
- lib/geometric_trans.rb
|
21
|
+
homepage: https://github.com/skinoyes/geometric_trans
|
22
|
+
licenses: []
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.7.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Geometric transformations
|
44
|
+
test_files: []
|