Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
Plane.cs
浏览该文件的文档.
1namespace Engine {
2 public struct Plane : IEquatable<Plane> {
3 public Vector3 Normal;
4
5 public float D;
6
7 public Plane(Vector4 v) => this = new Plane(new Vector3(v.X, v.Y, v.Z), v.W);
8
9 public Plane(Vector3 normal, float d) {
10 Normal = normal;
11 D = d;
12 }
13
14 public Plane(Vector3 a, Vector3 b, Vector3 c) {
15 Normal = Vector3.Normalize(Vector3.Cross(b - a, c - a));
16 D = 0f - Vector3.Dot(Normal, a);
17 }
18
19 public Plane(float x, float y, float z, float d) => this = new Plane(new Vector3(x, y, z), d);
20
21 public override bool Equals(object obj) => obj is Plane && Equals((Plane)obj);
22
23 public bool Equals(Plane other) => Normal == other.Normal && D == other.D;
24
25 public override int GetHashCode() => Normal.GetHashCode() + D.GetHashCode();
26
27 public override string ToString() => $"{Normal.X},{Normal.Y},{Normal.Z},{D}";
28
29 public static Plane Normalize(Plane p) {
30 float num = p.Normal.Length();
31 if (num > 0f) {
32 float num2 = 1f / num;
33 return new Plane(p.Normal * num2, p.D * num2);
34 }
35 return new Plane(Vector3.UnitX, 0f);
36 }
37
38 public static bool operator ==(Plane p1, Plane p2) => p1.Equals(p2);
39
40 public static bool operator !=(Plane p1, Plane p2) => !p1.Equals(p2);
41 }
42}
Engine.Vector3 Vector3
static bool operator!=(Plane p1, Plane p2)
Plane(Vector4 v)
定义 Plane.cs:7
override string ToString()
Plane(float x, float y, float z, float d)
override int GetHashCode()
bool Equals(Plane other)
override bool Equals(object obj)
Vector3 Normal
定义 Plane.cs:3
static bool operator==(Plane p1, Plane p2)
Plane(Vector3 a, Vector3 b, Vector3 c)
static Plane Normalize(Plane p)
Plane(Vector3 normal, float d)
定义 Plane.cs:9
static Vector3 Cross(Vector3 v1, Vector3 v2)
static Vector3 Normalize(Vector3 v)
static readonly Vector3 UnitX
static float Dot(Vector3 v1, Vector3 v2)