NavisworksTransport/src/Utils/CoordinateSystem/PathTargetFrame.cs

34 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Numerics;
namespace NavisworksTransport.Utils.CoordinateSystem
{
/// <summary>
/// 当前宿主语义下的路径目标框架。
/// Forward 表示路径前进方向Up 表示路径语义上的“向上/法向”Side 由二者叉乘得到。
/// </summary>
public sealed class PathTargetFrame
{
public PathTargetFrame(Vector3 forward, Vector3 up)
{
if (forward.LengthSquared() < 1e-12f)
{
throw new ArgumentException("forward 不能为空。", nameof(forward));
}
if (up.LengthSquared() < 1e-12f)
{
throw new ArgumentException("up 不能为空。", nameof(up));
}
Forward = Vector3.Normalize(forward);
Up = Vector3.Normalize(up);
Side = Vector3.Normalize(Vector3.Cross(Forward, Up));
}
public Vector3 Forward { get; }
public Vector3 Up { get; }
public Vector3 Side { get; }
}
}