Created
July 21, 2011 02:27
-
-
Save dreamr/1096386 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PANEL_WIDTH = 5.2; | |
var PANEL_HEIGHT = 2.5; | |
var PANEL_SPACING = 0.5; | |
function MountingArea(width, height) { | |
this.width = width; this.height = height; | |
this.solar_array = new SolarArray(width, height) | |
} | |
function SolarArray(width, height) { | |
var row_panel_count = Math.floor(parseFloat(width) / PANEL_WIDTH); | |
var column_panel_count = Math.floor(parseFloat(height) / PANEL_HEIGHT); | |
this.width = row_panel_count*(PANEL_WIDTH+PANEL_SPACING)-PANEL_SPACING; | |
this.height = column_panel_count*(PANEL_HEIGHT+PANEL_SPACING)-PANEL_SPACING; | |
this.panels = function() { | |
var panel_array = new Array(row_panel_count, column_panel_count) | |
for (i=0; i<row_panel_count; i++) { | |
for (j=0; j<column_panel_count; j++) { | |
panel_array[i, j] = new Panel(i, j); | |
} | |
} | |
return panel_array; | |
} | |
} | |
function Panel(row_index, column_index) { | |
this.width = PANEL_WIDTH; this.height = PANEL_HEIGHT; | |
this.row_index = row_index; this.column_index = column_index; | |
} | |
var mounting_area = new MountingArea(32.5, 42.8); | |
console.debug(mounting_area.solar_array.panels); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment