ladybug-tools / spider

:spider_web: 3D interactive analysis in your browser mostly written around the Three.js JavaScript library
http://www.ladybug.tools/spider
44 stars 15 forks source link

Coordinates for Roofs are Not ordered the right way in the polyloop #65

Closed chiensiTB closed 6 years ago

chiensiTB commented 6 years ago

Should form a normal that points on the [0 0 1] direction using the right hand rule. Appears the coordinates are pointing in the [0 0 -1] direction (floor slab and roof coordinates both ordered the same.

@theo-armour I will work on this and fix it.

storey-1-roof-space-1 90 none -50 -50 10 -35 -35 10 35 -35 10 50 -50 10
    <Surface surfaceType="SlabOnGrade" id="surface-2">
        <Name>storey-1-slabongrade-space-1</Name>
        <RectangularGeometry>
            <Azimuth>90</Azimuth>
        </RectangularGeometry>
        <CADOjectId>none</CADOjectId>
        <AdjacentSpaceId spaceIdRef="space-1"/>
        <PlanarGeometry>
            <PolyLoop>
                <CartesianPoint>
                    <Coordinate>-50</Coordinate>
                    <Coordinate>-50</Coordinate>
                    <Coordinate>0</Coordinate>
                </CartesianPoint>
            </PolyLoop>
            <PolyLoop>
                <CartesianPoint>
                    <Coordinate>-35</Coordinate>
                    <Coordinate>-35</Coordinate>
                    <Coordinate>0</Coordinate>
                </CartesianPoint>
            </PolyLoop>
            <PolyLoop>
                <CartesianPoint>
                    <Coordinate>35</Coordinate>
                    <Coordinate>-35</Coordinate>
                    <Coordinate>0</Coordinate>
                </CartesianPoint>
            </PolyLoop>
            <PolyLoop>
                <CartesianPoint>
                    <Coordinate>50</Coordinate>
                    <Coordinate>-50</Coordinate>
                    <Coordinate>0</Coordinate>
                </CartesianPoint>
            </PolyLoop>
        </PlanarGeometry>
    </Surface>
theo-armour commented 6 years ago

@chiensiTB

I have added a .clone() before reversing the array of coordinates in this line. The reversing is just to make the area calculations a positive number. Anyway, I think this could fix the issue.

https://github.com/ladybug-tools/spider/blob/master/cookbook/07-create-exportable-buildings/create-exportable-buildings-theo.html#L1306

The more important things is, how did you find this out? Was it just by inspecting the numbers by eye or do you have some way of testing for issues like this? If so, can you share?