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

Polyline / Polygon (3D) GetZ() function #35

Open
amastrobera opened this issue Oct 9, 2023 · 0 comments
Open

Polyline / Polygon (3D) GetZ() function #35

amastrobera opened this issue Oct 9, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@amastrobera
Copy link
Owner

amastrobera commented Oct 9, 2023

Given a Polyline3D and a Point2D (which belongs to it, in a 2D - XY view), find the corresponding Z coordinate.

Same for a Polygon3D.

something like this

              Func<G.Polyline3D, G.Point2D, double> GetZ = (G.Polyline3D _polyline, G.Point2D _p_2d) => {
                var _vertical_intersection =
                    _polyline.Intersection(G.Line3D.FromDirection(new G.Point3D(_p_2d.U, _p_2d.V, 0), G.Vector3D.AxisZ),
                                           decimal_precision);
                if (_vertical_intersection.ValueType == typeof(G.Point3D)) {
                  return ((G.Point3D)_vertical_intersection.Value).Z;
                }

                if (_vertical_intersection.ValueType == typeof(G.PointSet3D)) {
                  return ((G.PointSet3D)_vertical_intersection.Value).First().Z;
                }

                throw new Exception("failed to find z-coordinate for point (2D) on polyline (3D)");
              };
@amastrobera amastrobera added the enhancement New feature or request label Oct 9, 2023
@amastrobera amastrobera self-assigned this Oct 9, 2023
@amastrobera amastrobera removed their assignment Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant