-
Notifications
You must be signed in to change notification settings - Fork 13
Spatial_Engine: Add Orient method for IElements #2924
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
Merged
IsakNaslundBh
merged 11 commits into
main
from
Spatial_Engine-#2923-AddOrientMethodForIElements
Oct 11, 2022
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
691f718
Add Orient method for IElements
IsakNaslundBh d7df7d2
Add UTs for all valid types
IsakNaslundBh 6cb58c9
Fix issue with transform of FrameEdge modifying the incoming object
IsakNaslundBh 49f5427
Reganarated UTs after Facade fix
IsakNaslundBh 53968bd
Remove non base types from UT
IsakNaslundBh 0edf2b3
Default coordinate systems to world XY
IsakNaslundBh 66ef002
Include check for default value behaviour for coordinatesystems
IsakNaslundBh 644e575
Making coordinate system non optional again
IsakNaslundBh 33337c6
Remove returning same element for both systems null
IsakNaslundBh ab10cfe
remove default checks for UT
IsakNaslundBh 2f5ad8a
Descriptions
IsakNaslundBh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* This file is part of the Buildings and Habitats object Model (BHoM) | ||
* Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. | ||
* | ||
* Each contributor holds copyright over their respective contributions. | ||
* The project versioning (Git) records all such contribution source information. | ||
* | ||
* | ||
* The BHoM is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3.0 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The BHoM is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. | ||
*/ | ||
|
||
using BH.oM.Base; | ||
using BH.oM.Base.Attributes; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using BH.oM.Dimensional; | ||
using BH.oM.Geometry; | ||
using BH.oM.Geometry.CoordinateSystem; | ||
|
||
|
||
namespace BH.Engine.Spatial | ||
{ | ||
public static partial class Modify | ||
{ | ||
/***************************************************/ | ||
/**** Public Methods ****/ | ||
/***************************************************/ | ||
|
||
[Description("Orients the element from one coordinate system to another.")] | ||
[Input("element", "The element to orient.")] | ||
[Input("from", "The cartesian coordinate system to orient from.")] | ||
[Input("to", "The cartesian coordinate system to orient to.")] | ||
[Output("element", "The reoriented element.")] | ||
public static IElement Orient(this IElement element, Cartesian from, Cartesian to) | ||
{ | ||
if (element == null) | ||
{ | ||
Base.Compute.RecordError("Cannot Orient a null element."); | ||
return null; | ||
} | ||
|
||
if (from == null) | ||
{ | ||
Base.Compute.RecordError($"The {nameof(from)} coordinate system is null. Unable to orient the element. Null returned."); | ||
return null; | ||
} | ||
|
||
if (to == null) | ||
{ | ||
Base.Compute.RecordError($"The {nameof(to)} coordinate system is null. Unable to orient the element. Null returned."); | ||
return null; | ||
} | ||
|
||
TransformMatrix transformMatrix = Geometry.Create.OrientationMatrix(from, to); | ||
return element.ITransform(transformMatrix); | ||
} | ||
|
||
/***************************************************/ | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.