class URBANopt::GeoJSON::ScaleArea
Attributes
eps[R]
new_vertices[R]
one[R]
ten[R]
two[R]
zero[R]
Public Class Methods
new(vertices, desired_area, runner, eps)
click to toggle source
# File lib/urbanopt/geojson/scale_area.rb, line 29 def initialize(vertices, desired_area, runner, eps) @vertices = vertices @centroid = OpenStudio.getCentroid(vertices) raise "Cannot compute centroid for '#{vertices}'" if @centroid.empty? @centroid = @centroid.get @desired_area = desired_area @new_vertices = vertices @runner = runner @zero = BigDecimal('0.0') @one = BigDecimal('1.0') @two = BigDecimal('2.0') @ten = BigDecimal('10.0') @eps = eps end
Public Instance Methods
values(x)
click to toggle source
Used to determine new scaled vertices, by iteratively passing in the perimeter distance to minimise the difference of the new and scaled area. Returns the difference of the new area and desired area.
# File lib/urbanopt/geojson/scale_area.rb, line 58 def values(x) @new_vertices = URBANopt::GeoJSON::Zoning.divide_floor_print(@vertices, x[0].to_f, @runner, scale = true) new_area = OpenStudio.getArea(@new_vertices) raise "Cannot compute area for '#{@new_vertices}'" if new_area.empty? new_area = new_area.get return [new_area - @desired_area] end