-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Wrap Longitude #502
Wrap Longitude #502
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -355,5 +355,76 @@ define([ | |
return undefined; | ||
}; | ||
|
||
var lineSegmentPlaneDifference = new Cartesian3(); | ||
|
||
/** | ||
* Computes the intersection of a line segment and a plane. | ||
* @memberof IntersectionTests | ||
* | ||
* @param {Cartesian3} endPoint0 An end point of the line segment. | ||
* @param {Cartesian3} endPoint1 The other end point of the line segment. | ||
* @param {Cartesian3} planeNormal The plane normal. | ||
* @param {Number} planeD The distance from the plane to the origin. | ||
* @param {Cartesian3} [result] The object onto which to store the result. | ||
* @returns {Cartesian3} The intersection point or undefined if there is no intersection. | ||
* | ||
* @exception {DeveloperError} endPoint0 is required. | ||
* @exception {DeveloperError} endPoint1 is required. | ||
* @exception {DeveloperError} planeNormal is required. | ||
* @exception {DeveloperError} planeD is required. | ||
* | ||
* @example | ||
* var origin = ellipsoid.cartographicToCartesian(Cartographic.fromDegrees(-75.59777, 40.03883, 0.0)); | ||
* var normal = ellipsoid.geodeticSurfaceNormal(origin); | ||
* var constant = -Cartesian3.dot(normal, origin); | ||
* | ||
* var p0 = new Cartesian3(...); | ||
* var p1 = new Cartesian3(...); | ||
* | ||
* // find the intersection of the line segment from p0 to p1 and the tangent plane at origin. | ||
* var intersection = IntersectionTests.lineSegmentPlane(p0, p1, normal, constant); | ||
*/ | ||
IntersectionTests.lineSegmentPlane = function(endPoint0, endPoint1, planeNormal, planeD, result) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bummer, the Plane I added is still in a branch. No need to address it now. |
||
if (typeof endPoint0 === 'undefined') { | ||
throw new DeveloperError('endPoint0 is required.'); | ||
} | ||
|
||
if (typeof endPoint1 === 'undefined') { | ||
throw new DeveloperError('endPoint1 is required.'); | ||
} | ||
|
||
if (typeof planeNormal === 'undefined') { | ||
throw new DeveloperError('planeNormal is required.'); | ||
} | ||
|
||
if (typeof planeD === 'undefined') { | ||
throw new DeveloperError('planeD is required.'); | ||
} | ||
|
||
var difference = Cartesian3.subtract(endPoint1, endPoint0, lineSegmentPlaneDifference); | ||
var nDotDiff = Cartesian3.dot(planeNormal, difference); | ||
|
||
// check if the segment and plane are parallel | ||
if (Math.abs(nDotDiff) < CesiumMath.EPSILON6) { | ||
return undefined; | ||
} | ||
|
||
var nDotP0 = Cartesian3.dot(planeNormal, endPoint0); | ||
var t = -(planeD + nDotP0) / nDotDiff; | ||
|
||
// intersection only if t is in [0, 1] | ||
if (t < 0.0 || t > 1.0) { | ||
return undefined; | ||
} | ||
|
||
// intersection is endPoint0 + t * (endPoint1 - endPoint0) | ||
if (typeof result === 'undefined') { | ||
result = new Cartesian3(); | ||
} | ||
Cartesian3.multiplyByScalar(difference, t, result); | ||
Cartesian3.add(endPoint0, result, result); | ||
return result; | ||
}; | ||
|
||
return IntersectionTests; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -361,8 +361,8 @@ define([ | |
return positions; | ||
}; | ||
|
||
Polyline.prototype._createSegments = function(ellipsoid) { | ||
return PolylinePipeline.wrapLongitude(ellipsoid, this.getPositions()); | ||
Polyline.prototype._createSegments = function(modelMatrix) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is only one line now. Do we still need it? Actually, the whole segment management in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should wait until we start the material improvements. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeap, OK with me. |
||
return PolylinePipeline.wrapLongitude(this.getPositions(), modelMatrix); | ||
}; | ||
|
||
Polyline.prototype._setSegments = function(segments) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not an @example?