Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Corridor Geometry for sharp corners #2626

Merged
merged 2 commits into from
Apr 10, 2015
Merged

Fix Corridor Geometry for sharp corners #2626

merged 2 commits into from
Apr 10, 2015

Conversation

mramato
Copy link
Contributor

@mramato mramato commented Apr 8, 2015

As reported on the forum. The below code was generating an incorrect shape. I traced the problem down to a bad epsilon value in CorridorGeometryLibrary. I'm not at all confident in this area of the code, so @bagnell please double check my work. I also wasn't sure how to test it, so I just mimicked the other tests.

Should we have a single constant defined somewhere for all geometry epsilon checking?

var viewer = new Cesium.Viewer('cesiumContainer');

var blueCorridor = viewer.entities.add({
    name : 'Blue corridor',
    corridor : {
        positions : Cesium.Cartesian3.fromDegreesArray([
            2.00571672577652,52.7781459942399,
            1.99188457974115,52.7764958852886,
            2.01325961458495,52.7674170680511,
            1.98708058340534,52.7733979856253,
            2.00634853946644,52.7650460748473
        ]),
        height : 1000.0,
        extrudedHeight : 50.0,
        width : 100.0,
        cornerType: Cesium.CornerType.MITERED,
        material : Cesium.Color.BLUE.withAlpha(0.5),
        outline : true,
        outlineColor : Cesium.Color.BLUE
    }
});


var polyline = viewer.entities.add({
    name : 'Polyline',
    polyline : {
        positions : Cesium.Cartesian3.fromDegreesArray([
            2.00571672577652,52.7781459942399,
            1.99188457974115,52.7764958852886,
            2.01325961458495,52.7674170680511,
            1.98708058340534,52.7733979856253,
            2.00634853946644,52.7650460748473
        ]),
        height : 1000.0,
        width : 10.0,
        material : Cesium.Color.RED.withAlpha(0.5)
    }
});

viewer.zoomTo(viewer.entities);

@bagnell
Copy link
Contributor

bagnell commented Apr 8, 2015

This looks good to me. I introduced the bad epsilon for a fix where corridors should have been straight but had sharp corners instead. You should also add the same fix to the PolylineVolumeGeometry here

@mramato
Copy link
Contributor Author

mramato commented Apr 10, 2015

Yep, I managed to reproduce a similar problem in polyline volume with this code, which is now fixed.

var polylineVolume = viewer.entities.add({
    name : 'Polyline',
    polylineVolume : {
        shape : [new Cesium.Cartesian2(-100,-100), new Cesium.Cartesian2(-100,100),
                 new Cesium.Cartesian2(100,100), new Cesium.Cartesian2(100,-100)],
        positions : Cesium.Cartesian3.fromDegreesArrayHeights([
            2.00571672577652,52.7781459942399,500,
            1.99188457974115,52.7764958852886,500,
            2.01325961458495,52.7674170680511,500,
            1.98708058340534,52.7733979856253,500,
            2.00634853946644,52.7650460748473,500
        ]),
        material : Cesium.Color.RED,
        outline : true
    }
});

This is ready.

@bagnell
Copy link
Contributor

bagnell commented Apr 10, 2015

Looks good.

bagnell added a commit that referenced this pull request Apr 10, 2015
@bagnell bagnell merged commit fca05a7 into master Apr 10, 2015
@bagnell bagnell deleted the zig-zag-corridors branch April 10, 2015 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants