geo2d 0.1.2 → 0.1.3

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/geo2d.gemspec +2 -2
  3. data/lib/geo2d.rb +19 -11
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{geo2d}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Javier Goizueta"]
12
- s.date = %q{2009-11-22}
12
+ s.date = %q{2009-12-23}
13
13
  s.description = %q{Geo2D provides basic Planar Geometry functions for line-strings (poly-lines.)}
14
14
  s.email = %q{jgoizueta@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -124,14 +124,14 @@ module Geo2D
124
124
  end
125
125
  end
126
126
 
127
- end
128
-
129
- def distance_to(other)
130
- if other.kind_of?(Vector)
131
- (other-self).modulus
132
- else
133
- other.distance_to?(self)
127
+ def distance_to(other)
128
+ if other.kind_of?(Vector)
129
+ (other-self).modulus
130
+ else
131
+ other.distance_to?(self)
132
+ end
134
133
  end
134
+
135
135
  end
136
136
 
137
137
  module_function
@@ -234,12 +234,12 @@ module Geo2D
234
234
  if corrected
235
235
  # rotation = atan2(-(l.modulo(length))*d.sign, d.abs)
236
236
  if l<0
237
- rotation = Math.atan2(d < 0 ? -l : l, d.abs)
237
+ rotation = Math.atan2(d < 0 ? l : -l, d.abs)
238
238
  l = 0
239
239
  d = d/Math.cos(rotation) # d.sign*(point-@start).length
240
240
  elsif l>self.length
241
241
  l -= self.length
242
- rotation = Math.atan2(d < 0 ? -l : l, d.abs)
242
+ rotation = Math.atan2(d < 0 ? l : -l, d.abs)
243
243
  l = self.length
244
244
  d = d/Math.cos(rotation) # d = d.sign*(point-@end).length
245
245
  end
@@ -320,6 +320,14 @@ module Geo2D
320
320
  end
321
321
 
322
322
  end
323
+
324
+ def <<(p)
325
+ p = Geo2D.Point(*p)
326
+ if @vertices.last != p
327
+ @vertices << p
328
+ @length = nil
329
+ end
330
+ end
323
331
 
324
332
  def start
325
333
  @vertices.first
@@ -419,7 +427,7 @@ module Geo2D
419
427
 
420
428
  # multiply by matrix [[a11, a12], [a21, a22]]
421
429
  def transform(*t)
422
- LineString.new(*@vertices.map{|v| v.transforme(*t)})
430
+ LineString.new(*@vertices.map{|v| v.transform(*t)})
423
431
  end
424
432
 
425
433
  def apply(prc=nil, &blk)
@@ -496,7 +504,7 @@ module Geo2D
496
504
  def rotation_transform(angle)
497
505
  sn = Math.sin(angle)
498
506
  cs = Math.cos(angle)
499
- [cs, sn, -sn, cs]
507
+ [cs, -sn, sn, cs]
500
508
  end
501
509
 
502
510
  # Rotation transformation; given the center of rotation (a point, i.e. a Vector) and the angle
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geo2d
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Goizueta
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-22 00:00:00 +01:00
12
+ date: 2009-12-23 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency