Skip to content

Commit

Permalink
fix nomal point project plane
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Mar 2, 2023
1 parent a9901f0 commit ea4c075
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 344 deletions.
16 changes: 6 additions & 10 deletions OpenMEPSandbox/Geometry/Point.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@ private Point()
/// Project a point onto a plane
/// </summary>
/// <param name="point">point need to project</param>
/// <param name="planeNormal">vector normal of plane</param>
/// <param name="plane">plane to be project</param>
/// <returns name="point">new point projected on plane</returns>
public static Autodesk.DesignScript.Geometry.Point ProjectOntoPlane(
Autodesk.DesignScript.Geometry.Point point,
Autodesk.DesignScript.Geometry.Vector planeNormal)
Autodesk.DesignScript.Geometry.Plane plane)
{
double a = planeNormal.X;
double b = planeNormal.Y;
double c = planeNormal.Z;

double dx = (b * b + c * c) * point.X - (a * b) * point.Y - (a * c) * point.Z;
double dy = -(b * a) * point.X + (a * a + c * c) * point.Y - (b * c) * point.Z;
double dz = -(c * a) * point.X - (c * b) * point.Y + (a * a + b * b) * point.Z;
return Autodesk.DesignScript.Geometry.Point.ByCoordinates(dx, dy, dz);
Point3 point3 = point.ToGSharkType();
GShark.Geometry.Plane plane1 = plane.ToGSharkType();
Point3 projectedPoint = point3.ProjectToPlan(plane1);
return Autodesk.DesignScript.Geometry.Point.ByCoordinates(projectedPoint.X, projectedPoint.Y, projectedPoint.Z);
}

/// <summary>
Expand Down
Loading

0 comments on commit ea4c075

Please sign in to comment.