2012-09-17 15:41:18 +00:00
|
|
|
|
using System;
|
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.GZBuilder.Geometry {
|
2012-09-26 00:04:17 +00:00
|
|
|
|
public enum Line3DType
|
|
|
|
|
{
|
|
|
|
|
DEFAULT,
|
|
|
|
|
ACTIVATOR,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Line3D {
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// Coordinates
|
|
|
|
|
public Vector3D v1;
|
|
|
|
|
public Vector3D v2;
|
2012-09-26 00:04:17 +00:00
|
|
|
|
public Line3DType LineType { get { return lineType; } }
|
|
|
|
|
private Line3DType lineType;
|
2012-09-17 15:41:18 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// Constructors
|
2012-09-26 00:04:17 +00:00
|
|
|
|
public Line3D(Vector3D v1, Vector3D v2) {
|
2012-09-17 15:41:18 +00:00
|
|
|
|
this.v1 = v1;
|
|
|
|
|
this.v2 = v2;
|
2012-09-26 00:04:17 +00:00
|
|
|
|
this.lineType = Line3DType.DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Line3D(Vector3D v1, Vector3D v2, Line3DType lineType) {
|
|
|
|
|
this.v1 = v1;
|
|
|
|
|
this.v2 = v2;
|
|
|
|
|
this.lineType = lineType;
|
2012-09-17 15:41:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
public Vector3D GetDelta() { return v2 - v1; }
|
2012-09-17 15:41:18 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// This calculates the angle
|
|
|
|
|
public float GetAngle() {
|
|
|
|
|
// Calculate and return the angle
|
|
|
|
|
Vector2D d = GetDelta();
|
2013-04-11 09:27:16 +00:00
|
|
|
|
return -(float)Math.Atan2(-d.y, d.x) + Angle2D.PIHALF;//mxd // (float)Math.PI * 0.5f;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-09-17 15:41:18 +00:00
|
|
|
|
}
|