point2d 0.0.1
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/lib/point2d.rb +34 -0
- data/lib/point2d/sort.rb +11 -0
- metadata +45 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8635468a4dca7b54ed355ff6ab3c7d62d4ed3d7f
|
|
4
|
+
data.tar.gz: cc6db26296121ab6a6b81d11764c3b905b401bf8
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 16c486e2e41ee9685f472aa344dee19e740f876c548900256135e2f875b3093389ea01bd89ffa6a7a011ff0cddaa7ef2f70abfff5f77b0ec9cde0af10f52a4d9
|
|
7
|
+
data.tar.gz: 8a17c9a3c3df9edcadfa7dc62ec6d62696a377f27ae66d560378cd6c7edadbd086663588b46552accde6747ff629ce3ba298a0a46edc4e269a3529dd3399a535
|
data/lib/point2d.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
class Point2d
|
|
2
|
+
attr_accessor :x, :y
|
|
3
|
+
|
|
4
|
+
def initialize(x=0, y=0)
|
|
5
|
+
@x = x
|
|
6
|
+
@y = y
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def +(other)
|
|
10
|
+
Point2d.new(x+other.x, y+other.y)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def -(other)
|
|
14
|
+
Point2d.new(x-other.x, y-other.y)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def *(factor)
|
|
18
|
+
Point2d.new(x*factor, y*factor)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def /(factor)
|
|
22
|
+
Point2d.new(x/factor, y/factor)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def cross(other)
|
|
26
|
+
x*other.y - y*other.x
|
|
27
|
+
end
|
|
28
|
+
alias % cross
|
|
29
|
+
|
|
30
|
+
def dot(other)
|
|
31
|
+
x*other.x + y*other.y
|
|
32
|
+
end
|
|
33
|
+
alias ^ dot
|
|
34
|
+
end
|
data/lib/point2d/sort.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: point2d
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Daniel Ribeiro
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-02-28 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Defines some operations on 2d points
|
|
14
|
+
email: daniel@ribeiromoreira.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/point2d.rb
|
|
20
|
+
- lib/point2d/sort.rb
|
|
21
|
+
homepage: http://pufe.xyz/pega_bolsa
|
|
22
|
+
licenses:
|
|
23
|
+
- MIT
|
|
24
|
+
metadata: {}
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubyforge_project:
|
|
41
|
+
rubygems_version: 2.6.13
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: A data structure representing 2d points
|
|
45
|
+
test_files: []
|