sailcalc 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +118 -0
- data/Rakefile +3 -0
- data/lib/sailcalc.rb +33 -0
- data/lib/sailcalc/version.rb +3 -0
- data/sailcalc.gemspec +24 -0
- data/spec/sailcalc_spec.rb +59 -0
- data/spec/spec_helper.rb +1 -0
- data/tasks/rspec.rake +3 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aba36f27c999040fb014036457dda3f2442dbe00
|
4
|
+
data.tar.gz: bf84f8ba5685f299875bc26b856dc222087c684e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e35f387546c8eca7afd5b2fa8999036f61e1ea9473e73075fae7e4f46b7b1f697d788bf4b232639ed25a518a8c662e3d7a26845c672371273290646b98f828e3
|
7
|
+
data.tar.gz: b6c9766f622886bd888a940773d612f246f80dc4492ab90ca128b846aa3f336690b442f53a5a51c2c980f2340b1b532624b022541a8c43f22e335298b315557a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Trevor Reiff
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# Sailcalc
|
2
|
+
|
3
|
+
Gem provides access to commenly used sailboat and yacht design formula.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'sailcalc'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install sailcalc
|
20
|
+
|
21
|
+
## Methods
|
22
|
+
|
23
|
+
### Sailcalc.dl_ratio(disp, lwl)
|
24
|
+
|
25
|
+
Calculates the displacement to length ratio of the vessel.
|
26
|
+
Required Parameters.
|
27
|
+
|
28
|
+
* disp : vessel displacement in lbs.
|
29
|
+
* lwl : waterline length of vessel in ft.
|
30
|
+
|
31
|
+
```
|
32
|
+
Sailcalc.dl_ratio(20_000, 30)
|
33
|
+
=> 330.69
|
34
|
+
```
|
35
|
+
### Sailcalc.hull_speed(lwl)
|
36
|
+
|
37
|
+
Calculates the theoretical hull speed of the vessel.
|
38
|
+
Required Parameters.
|
39
|
+
|
40
|
+
* lwl : waterline length of vessel in ft.
|
41
|
+
|
42
|
+
```
|
43
|
+
Sailcalc.hull_speed(30)
|
44
|
+
=> 7.34
|
45
|
+
```
|
46
|
+
|
47
|
+
### Sailcalc.sa_disp(disp, sa)
|
48
|
+
|
49
|
+
Calculates the sail area to displacement ratio of the vessel.
|
50
|
+
Required Parameters.
|
51
|
+
|
52
|
+
* disp : vessel displacement in lbs.
|
53
|
+
* sa : sail area of vessel in sq.ft.
|
54
|
+
|
55
|
+
```
|
56
|
+
Sailcalc.sa_disp(18_250, 810)
|
57
|
+
=> 18.71
|
58
|
+
```
|
59
|
+
|
60
|
+
### Sailcalc.len_beam(loa, bmax)
|
61
|
+
|
62
|
+
Calculates the length to beam ratio of the vessel.
|
63
|
+
Required Parameters.
|
64
|
+
|
65
|
+
* loa : vessel length overall in ft.
|
66
|
+
* bmax : maximum beam of vessel in ft.
|
67
|
+
|
68
|
+
```
|
69
|
+
Sailcalc.len_beam(42, 14.5)
|
70
|
+
=> 2.9
|
71
|
+
```
|
72
|
+
|
73
|
+
### Sailcalc.cap(disp, bmax)
|
74
|
+
|
75
|
+
Calculates the "capsize number" of the vessel.
|
76
|
+
Required Parameters.
|
77
|
+
|
78
|
+
* disp : vessel displacement in lbs.
|
79
|
+
* bmax : maximum beam of vessel in ft.
|
80
|
+
|
81
|
+
```
|
82
|
+
Sailcalc.cap(18_500, 14)
|
83
|
+
=> 2.12
|
84
|
+
```
|
85
|
+
### Sailcalc.bal_disp(disp, bal)
|
86
|
+
|
87
|
+
Calculates the balast to displacement ratio of the vessel. returns a percentage.
|
88
|
+
Required Parameters.
|
89
|
+
|
90
|
+
* disp : vessel displacement in lbs.
|
91
|
+
* bal : vessel ballast weight in lbs.
|
92
|
+
|
93
|
+
```
|
94
|
+
Sailcalc.bal_disp(20_000, 9_200)
|
95
|
+
=> 46.0
|
96
|
+
```
|
97
|
+
|
98
|
+
### Sailcalc.mcr(disp, lwl, loa, bmax)
|
99
|
+
|
100
|
+
Calculates the motion comfort number of the vessel.
|
101
|
+
Required Parameters.
|
102
|
+
|
103
|
+
* disp : vessel displacement in lbs.
|
104
|
+
* lwl : waterline length of vessel in ft.
|
105
|
+
* loa : vessel length overall in ft.
|
106
|
+
* bmax : maximum beam of vessel in ft.
|
107
|
+
|
108
|
+
```
|
109
|
+
Sailcalc.mcr(20_000, 30, 34, 12.7)
|
110
|
+
=> 31.32
|
111
|
+
```
|
112
|
+
## Contributing
|
113
|
+
|
114
|
+
1. Fork it ( https://github.com/[my-github-username]/sailcalc/fork )
|
115
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
116
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
117
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
118
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/sailcalc.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "sailcalc/version"
|
2
|
+
|
3
|
+
class Sailcalc
|
4
|
+
def self.dl_ratio(disp, lwl)
|
5
|
+
longTons = disp.to_f / 2240
|
6
|
+
(longTons / (0.01 * lwl)**3).round(2)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.hull_speed(lwl)
|
10
|
+
(1.34 * (lwl.to_f)**0.5).round(2)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.sa_disp(disp, sa)
|
14
|
+
disp_cu_feet = disp / 64
|
15
|
+
(sa.to_f / (disp_cu_feet**0.6666)).round(2)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.len_beam(loa, bmax)
|
19
|
+
(loa.to_f / bmax).round(2)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.cap(disp, bmax)
|
23
|
+
(bmax.to_f / (disp/64)**0.3333).round(2)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.bal_disp(disp, bal)
|
27
|
+
((bal.to_f / disp)*100).round(2)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.mcr(disp, lwl, loa, bmax)
|
31
|
+
(disp / (0.6666*((0.7*lwl) + (0.3333*loa))*(bmax**1.3333))).round(2)
|
32
|
+
end
|
33
|
+
end
|
data/sailcalc.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sailcalc/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sailcalc"
|
8
|
+
spec.version = Sailcalc::VERSION
|
9
|
+
spec.authors = ["Trevor Reiff"]
|
10
|
+
spec.email = ["trevorreiff@gmail.com"]
|
11
|
+
spec.summary = %q{Common yacht design formulas.}
|
12
|
+
spec.description = %q{Common yacht design formulas.}
|
13
|
+
spec.homepage = "https://github.com/treiff/sailcalc"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
24
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sailcalc do
|
4
|
+
describe 'dl_ratio' do
|
5
|
+
subject { Sailcalc.dl_ratio(20000, 38) }
|
6
|
+
|
7
|
+
it 'calculates the displacement to length ratio' do
|
8
|
+
expect(subject).to eql(162.72)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'hull_speed' do
|
13
|
+
subject { Sailcalc.hull_speed(26) }
|
14
|
+
|
15
|
+
it 'calculates the hull speed of the displacement hull' do
|
16
|
+
expect(subject).to eql(6.83)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'sa_disp' do
|
21
|
+
subject { Sailcalc.sa_disp(20000, 680) }
|
22
|
+
|
23
|
+
it 'calculates the sail area to displacement ratio' do
|
24
|
+
expect(subject).to eql(14.79)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'len_beam' do
|
29
|
+
subject { Sailcalc.len_beam(40, 12) }
|
30
|
+
|
31
|
+
it 'calculates the length to beam ratio' do
|
32
|
+
expect(subject).to eql(3.33)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'cap' do
|
37
|
+
subject { Sailcalc.cap(24000, 12) }
|
38
|
+
|
39
|
+
it 'calculates the capsize ratio' do
|
40
|
+
expect(subject).to eql(1.66)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'bal_disp' do
|
45
|
+
subject { Sailcalc.bal_disp(24000, 9000) }
|
46
|
+
|
47
|
+
it 'calculates the balast to displacement ratio' do
|
48
|
+
expect(subject).to eql(37.5)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'mcr' do
|
53
|
+
subject { Sailcalc.mcr(32500, 39, 44, 13.5) }
|
54
|
+
|
55
|
+
it 'calculates the motion comfort ratio' do
|
56
|
+
expect(subject).to eql(36.15)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'sailcalc'
|
data/tasks/rspec.rake
ADDED
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sailcalc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Trevor Reiff
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
description: Common yacht design formulas.
|
56
|
+
email:
|
57
|
+
- trevorreiff@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/sailcalc.rb
|
68
|
+
- lib/sailcalc/version.rb
|
69
|
+
- sailcalc.gemspec
|
70
|
+
- spec/sailcalc_spec.rb
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
- tasks/rspec.rake
|
73
|
+
homepage: https://github.com/treiff/sailcalc
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.3
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Common yacht design formulas.
|
97
|
+
test_files:
|
98
|
+
- spec/sailcalc_spec.rb
|
99
|
+
- spec/spec_helper.rb
|