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

Security_Engine: Transform method added for CameraDevice #2392

Merged
merged 2 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci/Datasets/Security_Engine/Modify/Transform.json

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions Security_Engine/Modify/Transform.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2021, 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 System.Collections.Generic;
using BH.oM.Dimensional;
using BH.oM.Geometry;
using System.ComponentModel;
using BH.oM.Reflection.Attributes;
using BH.Engine.Geometry;
using BH.oM.Security.Elements;
using System.Linq;

namespace BH.Engine.Security
{
public static partial class Modify
{
/***************************************************/
/**** Interface Methods - IElements ****/
/***************************************************/

[Description("Transforms the CameraDevice's eye position and target position by the transform matrix. Only rigid body transformations are supported.")]
[Input("camera", "CameraDevice to transform.")]
[Input("transform", "Transform matrix.")]
[Input("tolerance", "Tolerance used in the check whether the input matrix is equivalent to the rigid body transformation.")]
[Output("transformed", "Modified CameraDevice with unchanged properties, but transformed eye position and target position.")]
public static CameraDevice Transform(this CameraDevice camera, TransformMatrix transform, double tolerance = Tolerance.Distance)
{
if (!transform.IsRigidTransformation(tolerance))
{
BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported.");
return null;
}

CameraDevice result = camera.GetShallowClone() as CameraDevice;
result.EyePosition = result.EyePosition.Transform(transform);
result.TargetPosition = result.TargetPosition.Transform(transform);
return result;
}

/***************************************************/
}
}


1 change: 1 addition & 0 deletions Security_Engine/Security_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Query\Centreline.cs" />
<Compile Include="Query\Geometry.cs" />
<Compile Include="Modify\Transform.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BHoM_Engine\BHoM_Engine.csproj">
Expand Down