Files
stgsharp/源代码/StgSharp/Geometries/PlainGeometry/Rectangle.cs
T

58 lines
1.6 KiB
C#

using StgSharp.Math;
using System.Numerics;
namespace StgSharp.Geometries
{
public class Rectangle : Polygon4
{
internal Point center;
public sealed override Point RefPoint0 => center;
public sealed override Point RefPoint1 => new Point(vertexMat.transpose.colum0);
public sealed override Point RefPoint2 => new Point(vertexMat.transpose.colum1);
public Rectangle(
float v0x, float v0y, float v0z,
float v1x, float v1y, float v1z,
float v2x, float v2y, float v2z,
float v3x, float v3y, float v3z
)
{
vertexMat.mat.colum0 = new Vector4(v0x, v0y, v0z, 0);
vertexMat.mat.colum1 = new Vector4(v1x, v1y, v1z, 0);
vertexMat.mat.colum2 = new Vector4(v2x, v2y, v2z, 0);
vertexMat.mat.colum3 = new Vector4(v3x, v3y, v3z, 0);
}
/// <summary>
/// 计算中心点相对于参考原点的位移
/// </summary>
/// <param name="tick">当前游戏刻</param>
/// <returns></returns>
public virtual Vec3d MovCenter(uint tick) => default(Vec3d);
public sealed override Vec3d MoveVertex2(uint tick)
{
return
new Vec3d(this.center.position.vec * 2 - vertexMat.mat.colum0);
}
public sealed override Vec3d MoveVertex3(uint tick)
{
return
new Vec3d(this.center.position.vec * 2 - vertexMat.mat.colum1);
}
internal sealed override void OnRender(uint tick)
{
tick -= bornTick;
this.MovCenter(tick);
}
}
}