[measurement-tools] Fix Measure Distance Tool: Incorrect distance, rise, and slope calculations in sheets with vertical exaggeration#1187
Conversation
…ations in sheets with vertical exaggeration
| private getDistances(): { distance: number, run: number, rise: number } { | ||
| if (this.drawingMetadata?.sheetToWorldTransform) { | ||
| // calculate distances in sheet coordinates | ||
| const adjustedStartPoint = this.adjustPointWithSheetToWorldTransform(this.adjustPointForGlobalOrigin(this.startPointRef.clone())); |
There was a problem hiding this comment.
Assuming startPointRef is in 'drawing' coordinates, shouldn't we first adjust the point with the sheet to world, THEN adjust the point for global origin?
There was a problem hiding this comment.
The transformation order follows the approach used in the LocationMeasurement tool, which has been stable and reliable (Ref: LocationMeasurement.ts#L290).
Since this method was originally implemented by Maxime, I believe he would be the best person to clarify the reasoning behind choosing this specific order.
@Maxime-Brassard, could you provide some insights on why adjustPointForGlobalOrigin is applied before sheetToWorldTransform in this tool?
Thanks!
There was a problem hiding this comment.
I believe Alex is right, I'd test it and see if results make sense.
I think the adjustment for global coordinate should be made on the 3d points.
If it's not that way in LocationMeasurement, it's probably an oversight and an coincidence that it worked so far.
I'd test it and change it across measurements if everything looks fine.
Issue
Since PR 837, the
MeasureDistanceToolhas supported scaling measurements in sheet drawings to represent real-world distances instead of sheet distances.However, it did not account for the vertical exaggeration factor, causing incorrect calculations for:
Solution
To ensure accurate calculations, the start and end points are transformed into 3D world coordinates using sheetToWorldTransform before computing:
This fix only applies to sheet drawings with vertical exaggeration and does not impact distance calculations in 3D world views.
Demonstration
