Class: BTAP::EQuest::DOEPolygon

Inherits:
DOECommand show all
Defined in:
lib/openstudio-standards/btap/equest.rb

Overview

This class makes it easier to deal with DOE Polygons.

Instance Attribute Summary collapse

Attributes inherited from DOECommand

#building, #children, #commandName, #commandType, #comments, #exempt, #keywordPairs, #non_utype_commands, #one_line_commands, #parents, #utype, #uvalue

Instance Method Summary collapse

Methods inherited from DOECommand

#basic_output, #check_keyword?, #depth, #doe_scope, #get_children, #get_children_of_command, #get_command_from_string, #get_keyword_value, #get_name, #get_parent, #get_parents, #name, #output, #remove, #remove_keyword_pair, #set_keyword_value, #set_parent

Constructor Details

#initializeDOEPolygon

The constructor.



1775
1776
1777
1778
1779
1780
# File 'lib/openstudio-standards/btap/equest.rb', line 1775

def initialize
  super()
  @point_list = Array.new()
  #Convert Keywork Pairs to points.

end

Instance Attribute Details

#point_listObject

Returns the value of attribute point_list.



1772
1773
1774
# File 'lib/openstudio-standards/btap/equest.rb', line 1772

def point_list
  @point_list
end

Instance Method Details

#create_point_listObject



1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
# File 'lib/openstudio-standards/btap/equest.rb', line 1782

def create_point_list()

  #Convert Keywork Pairs to points.
  @point_list.clear
  @keywordPairs.each do |array|

    array[1].match(/\(\s*(\-?\d*\.?\d*)\s*\,\s*(\-?\d*\.?\d*)\s*\)/)
    #puts array[1]

    point = OpenStudio::Point3d.new($1.to_f,$2.to_f,0.0)
    @point_list.push(point)
  end
  #      @point_list.each do |p|
  #        puts p.x.to_s + " " + p.y.to_s + " " + p.z.to_s + " "
  #      end
end

#get_areaObject

This method returns the area of the polygon.



1800
1801
1802
# File 'lib/openstudio-standards/btap/equest.rb', line 1800

def get_area
  openstudio::getArea(@points_list)
end

#get_azimuth(point_index) ⇒ Object



1827
1828
1829
1830
1831
1832
1833
# File 'lib/openstudio-standards/btap/equest.rb', line 1827

def get_azimuth(point_index)
  if @points_list.size < pointindex + 2
    return OpenStudio::radToDeg(OpenStudio::getAngle(@point_list.last - @point_list[0] , openstudio::Vector3d( 1.0, 0.0, 0.0)))
  else
    return OpenStudio::radToDeg(OpenStudio::getAngle(@point_list[point_index + 1] - @point_list[point_index] , openstudio::Vector3d( 1.0, 0.0, 0.0)))
  end
end

#get_length(point_index) ⇒ Object

This method must determine the length of the given point to the next point in the polygon list. If the point is the last point, then it will be the distance from the last point to the first. point_name is the string named keyword in the keyword pair list. Example: “DOEPolygon 2” = POLYGON

V1               = ( 0, 0 )
V2               = ( 0, 1 )
V3               = ( 2, 1 )
V4               = ( 2 ,0 )

get_length(3) should return “2” get_length(2) should return “1”



1818
1819
1820
1821
1822
1823
1824
# File 'lib/openstudio-standards/btap/equest.rb', line 1818

def get_length(point_index)
  if @points_list.size < pointindex + 2
    return OpenStudio::getDistance(@point_list[0],@point_list.last)
  else
    return OpenStudio::getDistance(@point_list[point_index],@point_list[point_index + 1] )
  end
end