【问题标题】:C# library similar to Unity's Transform component [closed]类似于 Unity 的 Transform 组件的 C# 库 [关闭]
【发布时间】:2021-11-29 22:16:10
【问题描述】:

我使用 Unity 制作了一些小型工程特定应用程序,因为我发现 Transform 组件以及 Quaternion 和 Vector3 类具有一些很棒的原生功能,可以让空间工作变得更加容易。

对于某些项目,我需要跳出 Unity 编辑器/引擎,并且想知道是否有具有类似功能且高度可移植的 C# 库可以放入 VS 项目中?

【问题讨论】:

    标签: c# visual-studio unity3d transform geospatial


    【解决方案1】:

    我认为最适合你的工作之一是Vim.Math3D,该包包含类

    • 向量

       Vector2 - Single precision X, Y
       Vector3 - Single precision X, Y, Z
       Vector4 - Single precision X, Y, Z, W
       DVector2 - Double precision X, Y, Z
       DVector3 - Single precision X, Y, Z
       DVector4 - Single precision X, Y, Z, W
       Int2 - Integer X, Y
       Int3 - Integer X, Y, Z
       Int4 - Integer X, Y
       Complex - Double precision Imaginary, Real
      
    • Pseudo-Vectors - 以下类缺少一些操作 向量

       Byte2 - Byte X, Y
       Byte3 - Byte X, Y, Z
       Byte4 - Byte X, Y, Z, W
       ColorRGB - Byte representation of color R, G, B
       ColorRGBA - Byte representation of color with Alpha R, G, B, A
       ColorHDR - High Defintion Range color representation, 4 floats, R, G, B, A
      
    • 旋转和变换

       Quaternion - Single precision quaternion rotation X, Y, Z, W
       DQuaternion - Single precision quaternion rotation X, Y, Z, W
       AxisAngle - Single precison rotation as Axis (Vector3) and Angle in radians
       Matrix4x4 - 4 x 4 Single Precision matrix in Row-Column - corder
       Transform - Single precision Position (Vector3) and Orientation (Quaternion)
       Euler - Single precision Euler engle rotation as Yaw (Z rotation), Pitch (X rotation), Roll (y rotation)
      
    • 几何结构和形状

       Plane - Single precision plane stored Normal (Vector3) and D (distance along normal from Origin)
       DPlane - Double precision plane stored Normal (Vector3) and D (distance along normal from Origin)
       Triangle - Single precision representation of triangle in 3 dimension as 3 Vector3 Points, A, B, and C
       Triangle2 - Single precision representation of triangle in 3 dimension as 3 Vector3 Points, A, B, and C
       Quad - Single precision representation of quadrilateral in 3 dimension as 4 Vector3 Points, A, B, C, and D
       DQuad - Double precision representation of quadrilateral in 3 dimension as 4 Vector3 Points, A, B, C, and D
      
    • 线条

       Line - Single precision line segment A and B
       Ray - Single precision Point and Direction in 3 dimensional space
       DRay - Double precision Point and Direction in 3 dimensional space
      
    • 区间和边界结构

       Interval - Single precision float interval (float Min, float Max)
       AABox - Single precision 3 dimensional axis-aligned bouncing box (Vector3 Min, Vector3 Max)
       AABox2D - Single precision 2 dimensional axis-aligned bouncing box (Vector2 Min, Vector2 Max)
       AABox4D - Single precision 4 dimensional axis-aligned bouncing box (Vector4 Min, Vector4 Max)
       DInterval - Double precision float interval (double Min, double Max)
       DAABox - Double precision 3 dimensional axis-aligned bouncing box (DVector3 Min, DVector3 Max)
       DAABox2D - Double precision 2 dimensional axis-aligned bouncing box (DVector2 Min, DVector2 Max)
       DAABox4D - Double precision 4 dimensional axis-aligned bouncing box (DVector4 Min, DVector4 Max)
       Sphere - Bounding sphere (Vector3 Center, float Radius)
       DSphere - Double precision bounding spehere (DVector3 Center, double Radius)
      
    • 替代坐标表示

       SphericalCoordinate - Radius, Azimuth (bearing), and Inclination (elevation angle)
       PolarCoordinate - Radius and Azimuth (bearing)
       LogPolarCoordinate - Rho (log of radial distance) and Azimuth
       CylindricalCoordinate - Radius, Azimuth (bearing) and Height
       HorizontalCoordinate - Azimuth (bearing) and Inclination
       GeoCoordinate - Latitude and Longitude
      
    • 运动

       LinearMotion - Velocity, Acceleration, and Scalar Friction
       AngularMotion - Velocity, Acceleration, and Scalar Friction
       Motion - LinearMotion and AngularMotion
      

    也可以查看一些与上述相关的库

    System.Numerics

    SharpDX Mathematics

    MonoGame

    Math.NET Spatial

    Math.NET Numerics

    Stride

    【讨论】:

      【解决方案2】:

      您可能会在此处找到您提到的类/结构的 Unity 源代码实现:

      矢量3:https://github.com/Unity-Technologies/UnityCsReference/blob/master/Runtime/Export/Math/Vector3.cs

      四元数:https://github.com/Unity-Technologies/UnityCsReference/blob/master/Runtime/Export/Math/Quaternion.cs

      变换相关的东西:https://github.com/Unity-Technologies/UnityCsReference/tree/master/Runtime/Transform/ScriptBindings

      也许您可以将此代码用作参考,甚至可以将其复制到您的项目中。请注意,我不知道许可证是否允许。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-19
      • 1970-01-01
      • 2011-06-26
      • 2011-12-25
      • 2012-05-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多