-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
2,125 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,9 @@ | ||
using Autodesk.Revit.DB; | ||
|
||
namespace OpenMEP.Geometry; | ||
namespace OpenMEP.Geometry; | ||
|
||
public class Point | ||
{ | ||
private Point() | ||
{ | ||
|
||
} | ||
|
||
/// <summary> | ||
/// Project a point onto a plane | ||
/// </summary> | ||
/// <param name="point">point need to project</param> | ||
/// <param name="planeNormal">vector normal of plane</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 ) | ||
{ | ||
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 ); | ||
} | ||
|
||
/// <summary> | ||
/// Get the centroid of a list of points | ||
/// </summary> | ||
/// <param name="points">list of points</param> | ||
/// <returns name="point">centroid</returns> | ||
public static Autodesk.DesignScript.Geometry.Point Centroid( List<Autodesk.DesignScript.Geometry.Point> points ) | ||
{ | ||
double x = 0; | ||
double y = 0; | ||
double z = 0; | ||
foreach ( Autodesk.DesignScript.Geometry.Point point in points ) | ||
{ | ||
x += point.X; | ||
y += point.Y; | ||
z += point.Z; | ||
} | ||
return Autodesk.DesignScript.Geometry.Point.ByCoordinates( x / points.Count, y / points.Count, z / points.Count ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.