using System; using System.Collections.Generic; using UnityEngine; namespace ProBuilder2.Common { // Token: 0x02000030 RID: 48 public static class pb_Math { // Token: 0x06000108 RID: 264 RVA: 0x00011B48 File Offset: 0x0000FF48 public static Vector2 PointInCircumference(float radius, float angleInDegrees, Vector2 origin) { float num = radius * Mathf.Cos(0.017453292f * angleInDegrees) + origin.x; float num2 = radius * Mathf.Sin(0.017453292f * angleInDegrees) + origin.y; return new Vector2(num, num2); } // Token: 0x06000109 RID: 265 RVA: 0x00011B8C File Offset: 0x0000FF8C public static Vector3 PointInSphere(float radius, float latitudeAngle, float longitudeAngle) { float num = radius * Mathf.Cos(0.017453292f * latitudeAngle) * Mathf.Sin(0.017453292f * longitudeAngle); float num2 = radius * Mathf.Sin(0.017453292f * latitudeAngle) * Mathf.Sin(0.017453292f * longitudeAngle); float num3 = radius * Mathf.Cos(0.017453292f * longitudeAngle); return new Vector3(num, num2, num3); } // Token: 0x0600010A RID: 266 RVA: 0x00011BEC File Offset: 0x0000FFEC public static float SignedAngle(Vector2 a, Vector2 b) { float num = Vector2.Angle(a, b); if (b.x - a.x < 0f) { num = 360f - num; } return num; } // Token: 0x0600010B RID: 267 RVA: 0x00011C24 File Offset: 0x00010024 private static float SqrDistance(Vector3 a, Vector3 b) { float num = b.x - a.x; float num2 = b.y - a.y; float num3 = b.z - a.z; return num * num + num2 * num2 + num3 * num3; } // Token: 0x0600010C RID: 268 RVA: 0x00011C6C File Offset: 0x0001006C public static float TriangleArea(Vector3 x, Vector3 y, Vector3 z) { float num = pb_Math.SqrDistance(x, y); float num2 = pb_Math.SqrDistance(y, z); float num3 = pb_Math.SqrDistance(z, x); return Mathf.Sqrt((2f * num * num2 + 2f * num2 * num3 + 2f * num3 * num - num * num - num2 * num2 - num3 * num3) / 16f); } // Token: 0x0600010D RID: 269 RVA: 0x00011CC8 File Offset: 0x000100C8 public static float PolygonArea(Vector3[] vertices, int[] indices) { float num = 0f; for (int i = 0; i < indices.Length; i += 3) { num += pb_Math.TriangleArea(vertices[indices[i]], vertices[indices[i + 1]], vertices[indices[i + 2]]); } return num; } // Token: 0x0600010E RID: 270 RVA: 0x00011D28 File Offset: 0x00010128 public static Vector2 RotateAroundPoint(this Vector2 v, Vector2 origin, float theta) { float x = origin.x; float y = origin.y; float num = v.x; float num2 = v.y; float num3 = Mathf.Sin(theta * 0.017453292f); float num4 = Mathf.Cos(theta * 0.017453292f); num -= x; num2 -= y; float num5 = num * num4 + num2 * num3; float num6 = -num * num3 + num2 * num4; num = num5 + x; num2 = num6 + y; return new Vector2(num, num2); } // Token: 0x0600010F RID: 271 RVA: 0x00011DA4 File Offset: 0x000101A4 public static Vector2 ScaleAroundPoint(this Vector2 v, Vector2 origin, Vector2 scale) { Vector2 vector = v - origin; vector = Vector2.Scale(vector, scale); return vector + origin; } // Token: 0x06000110 RID: 272 RVA: 0x00011DCC File Offset: 0x000101CC public static Vector2 Perpendicular(Vector2 a, Vector2 b) { float x = a.x; float y = a.y; float x2 = b.x; float y2 = b.y; Vector2 vector = new Vector2(-(y2 - y), x2 - x); return vector.normalized; } // Token: 0x06000111 RID: 273 RVA: 0x00011E10 File Offset: 0x00010210 public static Vector2 Perpendicular(Vector2 a) { Vector2 vector = new Vector2(-a.y, a.x); return vector.normalized; } // Token: 0x06000112 RID: 274 RVA: 0x00011E3C File Offset: 0x0001023C public static Vector2 ReflectPoint(Vector2 point, Vector2 a, Vector2 b) { Vector2 vector = b - a; Vector2 vector2 = new Vector2(-vector.y, vector.x); float num = Mathf.Sin(Vector2.Angle(vector, point - a) * 0.017453292f) * Vector2.Distance(point, a); return point + vector2 * (num * 2f) * ((Vector2.Dot(point - a, vector2) <= 0f) ? 1f : (-1f)); } // Token: 0x06000113 RID: 275 RVA: 0x00011EC8 File Offset: 0x000102C8 public static float DistancePointLineSegment(Vector2 p, Vector2 v, Vector2 w) { float num = (v.x - w.x) * (v.x - w.x) + (v.y - w.y) * (v.y - w.y); if (num == 0f) { return Vector2.Distance(p, v); } float num2 = Vector2.Dot(p - v, w - v) / num; if ((double)num2 < 0.0) { return Vector2.Distance(p, v); } if ((double)num2 > 1.0) { return Vector2.Distance(p, w); } Vector2 vector = v + num2 * (w - v); return Vector2.Distance(p, vector); } // Token: 0x06000114 RID: 276 RVA: 0x00011F8C File Offset: 0x0001038C public static float DistancePointLineSegment(Vector3 p, Vector3 v, Vector3 w) { float num = (v.x - w.x) * (v.x - w.x) + (v.y - w.y) * (v.y - w.y) + (v.z - w.z) * (v.z - w.z); if (num == 0f) { return Vector3.Distance(p, v); } float num2 = Vector3.Dot(p - v, w - v) / num; if ((double)num2 < 0.0) { return Vector3.Distance(p, v); } if ((double)num2 > 1.0) { return Vector3.Distance(p, w); } Vector3 vector = v + num2 * (w - v); return Vector3.Distance(p, vector); } // Token: 0x06000115 RID: 277 RVA: 0x00012070 File Offset: 0x00010470 public static Vector3 GetNearestPointRayRay(Vector3 ao, Vector3 ad, Vector3 bo, Vector3 bd) { if (ad == bd) { return ao; } Vector3 vector = bo - ao; float num = -Vector3.Dot(ad, bd) * Vector3.Dot(bd, vector) + Vector3.Dot(ad, vector) * Vector3.Dot(bd, bd); float num2 = Vector3.Dot(ad, ad) * Vector3.Dot(bd, bd) - Vector3.Dot(ad, bd) * Vector3.Dot(ad, bd); return ao + ad * (num / num2); } // Token: 0x06000116 RID: 278 RVA: 0x000120E4 File Offset: 0x000104E4 public static bool GetLineSegmentIntersect(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, ref Vector2 intersect) { intersect = Vector2.zero; Vector2 vector; vector.x = p1.x - p0.x; vector.y = p1.y - p0.y; Vector2 vector2; vector2.x = p3.x - p2.x; vector2.y = p3.y - p2.y; float num = (-vector.y * (p0.x - p2.x) + vector.x * (p0.y - p2.y)) / (-vector2.x * vector.y + vector.x * vector2.y); float num2 = (vector2.x * (p0.y - p2.y) - vector2.y * (p0.x - p2.x)) / (-vector2.x * vector.y + vector.x * vector2.y); if (num >= 0f && num <= 1f && num2 >= 0f && num2 <= 1f) { intersect.x = p0.x + num2 * vector.x; intersect.y = p0.y + num2 * vector.y; return true; } return false; } // Token: 0x06000117 RID: 279 RVA: 0x00012258 File Offset: 0x00010658 public static bool GetLineSegmentIntersect(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3) { Vector2 vector; vector.x = p1.x - p0.x; vector.y = p1.y - p0.y; Vector2 vector2; vector2.x = p3.x - p2.x; vector2.y = p3.y - p2.y; float num = (-vector.y * (p0.x - p2.x) + vector.x * (p0.y - p2.y)) / (-vector2.x * vector.y + vector.x * vector2.y); float num2 = (vector2.x * (p0.y - p2.y) - vector2.y * (p0.x - p2.x)) / (-vector2.x * vector.y + vector.x * vector2.y); return num >= 0f && num <= 1f && num2 >= 0f && num2 <= 1f; } // Token: 0x06000118 RID: 280 RVA: 0x00012390 File Offset: 0x00010790 public static bool PointInPolygon(Vector2[] polygon, Vector2 point, int[] indices = null) { int num = ((indices == null) ? polygon.Length : indices.Length); if (num % 2 != 0) { Debug.LogError("PointInPolygon requires polygon indices be divisible by 2!"); return false; } pb_Bounds2D pb_Bounds2D = new pb_Bounds2D(polygon, indices); if (pb_Bounds2D.ContainsPoint(point)) { Vector2 vector = pb_Bounds2D.center + Vector2.up * (pb_Bounds2D.size.y + 2f); int num2 = 0; for (int i = 0; i < num; i += 2) { int num3 = ((indices == null) ? i : indices[i]); int num4 = ((indices == null) ? (i + 1) : indices[i + 1]); if (pb_Math.GetLineSegmentIntersect(vector, point, polygon[num3], polygon[num4])) { num2++; } } return num2 % 2 != 0; } return false; } // Token: 0x06000119 RID: 281 RVA: 0x0001247C File Offset: 0x0001087C public static bool PointInPolygon(Vector2[] polygon, pb_Bounds2D polyBounds, pb_Edge[] edges, Vector2 point) { int num = edges.Length * 2; Vector2 vector = polyBounds.center + Vector2.up * (polyBounds.size.y + 2f); int num2 = 0; for (int i = 0; i < num; i += 2) { if (pb_Math.GetLineSegmentIntersect(vector, point, polygon[i], polygon[i + 1])) { num2++; } } return num2 % 2 != 0; } // Token: 0x0600011A RID: 282 RVA: 0x00012508 File Offset: 0x00010908 public static bool RectIntersectsLineSegment(Rect rect, Vector2 a, Vector2 b) { Vector2 vector = new Vector2(rect.xMin, rect.yMax); Vector2 vector2 = new Vector2(rect.xMax, rect.yMax); Vector2 vector3 = new Vector2(rect.xMin, rect.yMin); Vector2 vector4 = new Vector2(rect.xMax, rect.yMin); return pb_Math.GetLineSegmentIntersect(vector2, vector, a, b) || pb_Math.GetLineSegmentIntersect(vector, vector3, a, b) || pb_Math.GetLineSegmentIntersect(vector3, vector4, a, b) || pb_Math.GetLineSegmentIntersect(vector4, vector, a, b); } // Token: 0x0600011B RID: 283 RVA: 0x000125A0 File Offset: 0x000109A0 public static bool RayIntersectsTriangle(Ray InRay, Vector3 InTriangleA, Vector3 InTriangleB, Vector3 InTriangleC, out float OutDistance, out Vector3 OutPoint) { OutDistance = 0f; OutPoint = Vector3.zero; Vector3 vector = InTriangleB - InTriangleA; Vector3 vector2 = InTriangleC - InTriangleA; Vector3 vector3 = Vector3.Cross(InRay.direction, vector2); float num = Vector3.Dot(vector, vector3); if (num > -Mathf.Epsilon && num < Mathf.Epsilon) { return false; } float num2 = 1f / num; Vector3 vector4 = InRay.origin - InTriangleA; float num3 = Vector3.Dot(vector4, vector3) * num2; if (num3 < 0f || num3 > 1f) { return false; } Vector3 vector5 = Vector3.Cross(vector4, vector); float num4 = Vector3.Dot(InRay.direction, vector5) * num2; if (num4 < 0f || num3 + num4 > 1f) { return false; } float num5 = Vector3.Dot(vector2, vector5) * num2; if (num5 > Mathf.Epsilon) { OutDistance = num5; OutPoint.x = num3 * InTriangleB.x + num4 * InTriangleC.x + (1f - (num3 + num4)) * InTriangleA.x; OutPoint.y = num3 * InTriangleB.y + num4 * InTriangleC.y + (1f - (num3 + num4)) * InTriangleA.y; OutPoint.z = num3 * InTriangleB.z + num4 * InTriangleC.z + (1f - (num3 + num4)) * InTriangleA.z; return true; } return false; } // Token: 0x0600011C RID: 284 RVA: 0x0001272C File Offset: 0x00010B2C public static bool RayIntersectsTriangle2(Vector3 origin, Vector3 dir, Vector3 vert0, Vector3 vert1, Vector3 vert2, ref float distance, ref Vector3 normal) { pb_Math.Subtract(vert0, vert1, ref pb_Math.tv1); pb_Math.Subtract(vert0, vert2, ref pb_Math.tv2); pb_Math.Cross(dir, pb_Math.tv2, ref pb_Math.tv4); float num = Vector3.Dot(pb_Math.tv1, pb_Math.tv4); if (num < Mathf.Epsilon) { return false; } pb_Math.Subtract(vert0, origin, ref pb_Math.tv3); float num2 = Vector3.Dot(pb_Math.tv3, pb_Math.tv4); if (num2 < 0f || num2 > num) { return false; } pb_Math.Cross(pb_Math.tv3, pb_Math.tv1, ref pb_Math.tv4); float num3 = Vector3.Dot(dir, pb_Math.tv4); if (num3 < 0f || num2 + num3 > num) { return false; } distance = Vector3.Dot(pb_Math.tv2, pb_Math.tv4) * (1f / num); pb_Math.Cross(pb_Math.tv1, pb_Math.tv2, ref normal); return true; } // Token: 0x0600011D RID: 285 RVA: 0x00012811 File Offset: 0x00010C11 public static float Secant(float x) { return 1f / Mathf.Cos(x); } // Token: 0x0600011E RID: 286 RVA: 0x00012820 File Offset: 0x00010C20 public static Vector3 Normal(Vector3 p0, Vector3 p1, Vector3 p2) { float num = p1.x - p0.x; float num2 = p1.y - p0.y; float num3 = p1.z - p0.z; float num4 = p2.x - p0.x; float num5 = p2.y - p0.y; float num6 = p2.z - p0.z; Vector3 zero = Vector3.zero; pb_Math.Cross(num, num2, num3, num4, num5, num6, ref zero.x, ref zero.y, ref zero.z); if (zero.magnitude < Mathf.Epsilon) { return new Vector3(0f, 0f, 0f); } zero.Normalize(); return zero; } // Token: 0x0600011F RID: 287 RVA: 0x000128E8 File Offset: 0x00010CE8 public static Vector3 Normal(IList vertices, IList indices = null) { if (indices == null || indices.Count % 3 != 0) { Vector3 vector = Vector3.Cross(vertices[1].position - vertices[0].position, vertices[2].position - vertices[0].position); vector.Normalize(); return vector; } int count = indices.Count; Vector3 vector2 = Vector3.zero; for (int i = 0; i < count; i += 3) { vector2 += pb_Math.Normal(vertices[indices[i]].position, vertices[indices[i + 1]].position, vertices[indices[i + 2]].position); } vector2 /= (float)count / 3f; vector2.Normalize(); return vector2; } // Token: 0x06000120 RID: 288 RVA: 0x000129D0 File Offset: 0x00010DD0 public static Vector3 Normal(pb_Object pb, pb_Face face) { Vector3[] vertices = pb.vertices; Vector3 vector = pb_Math.Normal(vertices[face.indices[0]], vertices[face.indices[1]], vertices[face.indices[2]]); if (face.indices.Length > 7) { Vector3 normal = pb_Projection.FindBestPlane(vertices, face.distinctIndices).normal; if (Vector3.Dot(vector, normal) < 0f) { vector.x = -normal.x; vector.y = -normal.y; vector.z = -normal.z; } else { vector.x = normal.x; vector.y = normal.y; vector.z = normal.z; } } return vector; } // Token: 0x06000121 RID: 289 RVA: 0x00012AB4 File Offset: 0x00010EB4 public static Vector3 Normal(IList p) { if (p == null || p.Count < 3) { return Vector3.zero; } int count = p.Count; if (count % 3 == 0) { Vector3 vector = Vector3.zero; for (int i = 0; i < count; i += 3) { vector += pb_Math.Normal(p[i], p[i + 1], p[i + 2]); } vector /= (float)count / 3f; vector.Normalize(); return vector; } Vector3 vector2 = Vector3.Cross(p[1] - p[0], p[2] - p[0]); if (vector2.magnitude < Mathf.Epsilon) { return new Vector3(0f, 0f, 0f); } return vector2.normalized; } // Token: 0x06000122 RID: 290 RVA: 0x00012B98 File Offset: 0x00010F98 public static void NormalTangentBitangent(pb_Object pb, pb_Face face, out Vector3 normal, out Vector3 tangent, out Vector3 bitangent) { if (face.indices.Length < 3) { Debug.LogWarning("Cannot find normal / tangent / bitangent for face with < 3 indices."); normal = Vector3.zero; tangent = Vector3.zero; bitangent = Vector3.zero; return; } normal = pb_Math.Normal(pb, face); Vector3 vector = Vector3.zero; Vector3 vector2 = Vector3.zero; Vector4 vector3 = new Vector4(0f, 0f, 0f, 1f); long num = (long)face.indices[0]; long num2 = (long)face.indices[1]; long num3 = (long)face.indices[2]; Vector3 vector4; Vector3 vector5; Vector3 vector6; Vector2 vector7; Vector2 vector8; Vector2 vector9; checked { vector4 = pb.vertices[(int)((IntPtr)num)]; vector5 = pb.vertices[(int)((IntPtr)num2)]; vector6 = pb.vertices[(int)((IntPtr)num3)]; vector7 = pb.uv[(int)((IntPtr)num)]; vector8 = pb.uv[(int)((IntPtr)num2)]; vector9 = pb.uv[(int)((IntPtr)num3)]; } float num4 = vector5.x - vector4.x; float num5 = vector6.x - vector4.x; float num6 = vector5.y - vector4.y; float num7 = vector6.y - vector4.y; float num8 = vector5.z - vector4.z; float num9 = vector6.z - vector4.z; float num10 = vector8.x - vector7.x; float num11 = vector9.x - vector7.x; float num12 = vector8.y - vector7.y; float num13 = vector9.y - vector7.y; float num14 = 1f / (num10 * num13 - num11 * num12); Vector3 vector10 = new Vector3((num13 * num4 - num12 * num5) * num14, (num13 * num6 - num12 * num7) * num14, (num13 * num8 - num12 * num9) * num14); Vector3 vector11 = new Vector3((num10 * num5 - num11 * num4) * num14, (num10 * num7 - num11 * num6) * num14, (num10 * num9 - num11 * num8) * num14); vector += vector10; vector2 += vector11; Vector3 vector12 = normal; Vector3.OrthoNormalize(ref vector12, ref vector); vector3.x = vector.x; vector3.y = vector.y; vector3.z = vector.z; vector3.w = ((Vector3.Dot(Vector3.Cross(vector12, vector), vector2) >= 0f) ? 1f : (-1f)); tangent = vector3 * vector3.w; bitangent = Vector3.Cross(normal, tangent); } // Token: 0x06000123 RID: 291 RVA: 0x00012E7C File Offset: 0x0001127C public static bool IsCardinalAxis(Vector3 v, float epsilon = 1E-05f) { v.Normalize(); return 1f - Mathf.Abs(Vector3.Dot(Vector3.up, v)) < epsilon || 1f - Mathf.Abs(Vector3.Dot(Vector3.forward, v)) < epsilon || 1f - Mathf.Abs(Vector3.Dot(Vector3.right, v)) < epsilon; } // Token: 0x06000124 RID: 292 RVA: 0x00012EE4 File Offset: 0x000112E4 public static T Max(T[] array) where T : IComparable { if (array == null || array.Length < 1) { return default(T); } T t = array[0]; for (int i = 1; i < array.Length; i++) { if (array[i].CompareTo(t) >= 0) { t = array[i]; } } return t; } // Token: 0x06000125 RID: 293 RVA: 0x00012F4C File Offset: 0x0001134C public static T Min(T[] array) where T : IComparable { if (array == null || array.Length < 1) { return default(T); } T t = array[0]; for (int i = 1; i < array.Length; i++) { if (array[i].CompareTo(t) < 0) { t = array[i]; } } return t; } // Token: 0x06000126 RID: 294 RVA: 0x00012FB4 File Offset: 0x000113B4 public static float LargestValue(Vector3 v) { if (v.x > v.y && v.x > v.z) { return v.x; } if (v.y > v.x && v.y > v.z) { return v.y; } return v.z; } // Token: 0x06000127 RID: 295 RVA: 0x00013024 File Offset: 0x00011424 public static float LargestValue(Vector2 v) { return (v.x <= v.y) ? v.y : v.x; } // Token: 0x06000128 RID: 296 RVA: 0x0001304C File Offset: 0x0001144C public static Vector2 SmallestVector2(Vector2[] v) { int num = v.Length; Vector2 vector = v[0]; for (int i = 0; i < num; i++) { if (v[i].x < vector.x) { vector.x = v[i].x; } if (v[i].y < vector.y) { vector.y = v[i].y; } } return vector; } // Token: 0x06000129 RID: 297 RVA: 0x000130D4 File Offset: 0x000114D4 public static Vector2 SmallestVector2(Vector2[] v, int[] indices) { int num = indices.Length; Vector2 vector = v[indices[0]]; for (int i = 0; i < num; i++) { if (v[indices[i]].x < vector.x) { vector.x = v[indices[i]].x; } if (v[indices[i]].y < vector.y) { vector.y = v[indices[i]].y; } } return vector; } // Token: 0x0600012A RID: 298 RVA: 0x00013168 File Offset: 0x00011568 public static Vector2 LargestVector2(Vector2[] v) { int num = v.Length; Vector2 vector = v[0]; for (int i = 0; i < num; i++) { if (v[i].x > vector.x) { vector.x = v[i].x; } if (v[i].y > vector.y) { vector.y = v[i].y; } } return vector; } // Token: 0x0600012B RID: 299 RVA: 0x000131F0 File Offset: 0x000115F0 public static Vector2 LargestVector2(Vector2[] v, int[] indices) { int num = indices.Length; Vector2 vector = v[indices[0]]; for (int i = 0; i < num; i++) { if (v[indices[i]].x > vector.x) { vector.x = v[indices[i]].x; } if (v[indices[i]].y > vector.y) { vector.y = v[indices[i]].y; } } return vector; } // Token: 0x0600012C RID: 300 RVA: 0x00013284 File Offset: 0x00011684 public static Vector3 BoundsCenter(Vector3[] verts) { if (verts.Length < 1) { return Vector3.zero; } Vector3 vector = verts[0]; Vector3 vector2 = vector; for (int i = 1; i < verts.Length; i++) { vector.x = Mathf.Min(verts[i].x, vector.x); vector2.x = Mathf.Max(verts[i].x, vector2.x); vector.y = Mathf.Min(verts[i].y, vector.y); vector2.y = Mathf.Max(verts[i].y, vector2.y); vector.z = Mathf.Min(verts[i].z, vector.z); vector2.z = Mathf.Max(verts[i].z, vector2.z); } return (vector + vector2) * 0.5f; } // Token: 0x0600012D RID: 301 RVA: 0x00013390 File Offset: 0x00011790 public static Vector2 Average(IList v, IList indices = null) { Vector2 vector = Vector2.zero; float num = (float)((indices != null) ? indices.Count : v.Count); if (indices == null) { int num2 = 0; while ((float)num2 < num) { vector += v[num2]; num2++; } } else { int num3 = 0; while ((float)num3 < num) { vector += v[indices[num3]]; num3++; } } return vector / num; } // Token: 0x0600012E RID: 302 RVA: 0x00013418 File Offset: 0x00011818 public static Vector3 Average(IList v, IList indices = null) { Vector3 zero = Vector3.zero; float num = (float)((indices != null) ? indices.Count : v.Count); if (indices == null) { int num2 = 0; while ((float)num2 < num) { zero.x += v[num2].x; zero.y += v[num2].y; zero.z += v[num2].z; num2++; } } else { int num3 = 0; while ((float)num3 < num) { zero.x += v[indices[num3]].x; zero.y += v[indices[num3]].y; zero.z += v[indices[num3]].z; num3++; } } return zero / num; } // Token: 0x0600012F RID: 303 RVA: 0x00013548 File Offset: 0x00011948 public static Vector3 Average(this IList v, Func selector, IList indices = null) { Vector3 vector = Vector3.zero; float num = (float)((indices != null) ? indices.Count : v.Count); if (indices == null) { int num2 = 0; while ((float)num2 < num) { vector += selector(v[num2]); num2++; } } else { int num3 = 0; while ((float)num3 < num) { vector += selector(v[indices[num3]]); num3++; } } return vector / num; } // Token: 0x06000130 RID: 304 RVA: 0x000135DC File Offset: 0x000119DC public static Vector4 Average(IList v, IList indices = null) { Vector4 vector = Vector4.zero; float num = (float)((indices != null) ? indices.Count : v.Count); if (indices == null) { int num2 = 0; while ((float)num2 < num) { vector += v[num2]; num2++; } } else { int num3 = 0; while ((float)num3 < num) { vector += v[indices[num3]]; num3++; } } return vector / num; } // Token: 0x06000131 RID: 305 RVA: 0x00013664 File Offset: 0x00011A64 public static Color Average(IList c, IList indices = null) { Color color = c[0]; float num = (float)((indices != null) ? indices.Count : c.Count); if (indices == null) { int num2 = 1; while ((float)num2 < num) { color += c[num2]; num2++; } } else { int num3 = 1; while ((float)num3 < num) { color += c[indices[num3]]; num3++; } } return color / num; } // Token: 0x06000132 RID: 306 RVA: 0x000136EC File Offset: 0x00011AEC public static bool Approx2(this Vector2 v, Vector2 b, float delta = 0.0001f) { return Mathf.Abs(v.x - b.x) < delta && Mathf.Abs(v.y - b.y) < delta; } // Token: 0x06000133 RID: 307 RVA: 0x00013724 File Offset: 0x00011B24 public static bool Approx3(this Vector3 v, Vector3 b, float delta = 0.0001f) { return Mathf.Abs(v.x - b.x) < delta && Mathf.Abs(v.y - b.y) < delta && Mathf.Abs(v.z - b.z) < delta; } // Token: 0x06000134 RID: 308 RVA: 0x00013780 File Offset: 0x00011B80 public static bool Approx4(this Vector4 v, Vector4 b, float delta = 0.0001f) { return Mathf.Abs(v.x - b.x) < delta && Mathf.Abs(v.y - b.y) < delta && Mathf.Abs(v.z - b.z) < delta && Mathf.Abs(v.w - b.w) < delta; } // Token: 0x06000135 RID: 309 RVA: 0x000137F8 File Offset: 0x00011BF8 public static bool ApproxC(this Color a, Color b, float delta = 0.0001f) { return Mathf.Abs(a.r - b.r) < delta && Mathf.Abs(a.g - b.g) < delta && Mathf.Abs(a.b - b.b) < delta && Mathf.Abs(a.a - b.a) < delta; } // Token: 0x06000136 RID: 310 RVA: 0x0001386D File Offset: 0x00011C6D public static bool Approx(this float a, float b, float delta = 0.0001f) { return Mathf.Abs(b - a) < Mathf.Abs(delta); } // Token: 0x06000137 RID: 311 RVA: 0x00013880 File Offset: 0x00011C80 public static bool ContainsApprox(Vector3[] v, Vector3 p, float eps) { for (int i = 0; i < v.Length; i++) { if (v[i].Approx3(p, eps)) { return true; } } return false; } // Token: 0x06000138 RID: 312 RVA: 0x000138BC File Offset: 0x00011CBC public static int Wrap(int value, int lowerBound, int upperBound) { int num = upperBound - lowerBound + 1; if (value < lowerBound) { value += num * ((lowerBound - value) / num + 1); } return lowerBound + (value - lowerBound) % num; } // Token: 0x06000139 RID: 313 RVA: 0x000138EA File Offset: 0x00011CEA public static int Clamp(int value, int lowerBound, int upperBound) { return (value >= lowerBound) ? ((value <= upperBound) ? value : upperBound) : lowerBound; } // Token: 0x0600013A RID: 314 RVA: 0x00013908 File Offset: 0x00011D08 public static Vector2 ToMask(this Vector2 vec, float delta = 1E-45f) { return new Vector2((Mathf.Abs(vec.x) <= delta) ? 0f : 1f, (Mathf.Abs(vec.y) <= delta) ? 0f : 1f); } // Token: 0x0600013B RID: 315 RVA: 0x0001395C File Offset: 0x00011D5C public static Vector3 ToMask(this Vector3 vec, float delta = 1E-45f) { return new Vector3((Mathf.Abs(vec.x) <= delta) ? 0f : 1f, (Mathf.Abs(vec.y) <= delta) ? 0f : 1f, (Mathf.Abs(vec.z) <= delta) ? 0f : 1f); } // Token: 0x0600013C RID: 316 RVA: 0x000139D4 File Offset: 0x00011DD4 public static Vector3 ToSignedMask(this Vector3 vec, float delta = 1E-45f) { return new Vector3((Mathf.Abs(vec.x) <= delta) ? 0f : (vec.x / Mathf.Abs(vec.x)), (Mathf.Abs(vec.y) <= delta) ? 0f : (vec.y / Mathf.Abs(vec.y)), (Mathf.Abs(vec.z) <= delta) ? 0f : (vec.z / Mathf.Abs(vec.z))); } // Token: 0x0600013D RID: 317 RVA: 0x00013A76 File Offset: 0x00011E76 public static Vector3 Abs(this Vector3 v) { return new Vector3(Mathf.Abs(v.x), Mathf.Abs(v.y), Mathf.Abs(v.z)); } // Token: 0x0600013E RID: 318 RVA: 0x00013AA1 File Offset: 0x00011EA1 public static int IntSum(this Vector3 mask) { return (int)Mathf.Abs(mask.x) + (int)Mathf.Abs(mask.y) + (int)Mathf.Abs(mask.z); } // Token: 0x0600013F RID: 319 RVA: 0x00013ACC File Offset: 0x00011ECC public static void Cross(Vector3 a, Vector3 b, ref float x, ref float y, ref float z) { x = a.y * b.z - a.z * b.y; y = a.z * b.x - a.x * b.z; z = a.x * b.y - a.y * b.x; } // Token: 0x06000140 RID: 320 RVA: 0x00013B40 File Offset: 0x00011F40 public static void Cross(Vector3 a, Vector3 b, ref Vector3 res) { res.x = a.y * b.z - a.z * b.y; res.y = a.z * b.x - a.x * b.z; res.z = a.x * b.y - a.y * b.x; } // Token: 0x06000141 RID: 321 RVA: 0x00013BBC File Offset: 0x00011FBC public static void Cross(float ax, float ay, float az, float bx, float by, float bz, ref float x, ref float y, ref float z) { x = ay * bz - az * by; y = az * bx - ax * bz; z = ax * by - ay * bx; } // Token: 0x06000142 RID: 322 RVA: 0x00013BE0 File Offset: 0x00011FE0 public static void Subtract(Vector3 a, Vector3 b, ref Vector3 res) { res.x = b.x - a.x; res.y = b.y - a.y; res.z = b.z - a.z; } // Token: 0x04000126 RID: 294 public const float PHI = 1.618034f; // Token: 0x04000127 RID: 295 public const float FLT_EPSILON = 1E-45f; // Token: 0x04000128 RID: 296 public const float FLT_COMPARE_EPSILON = 0.0001f; // Token: 0x04000129 RID: 297 public const float HANDLE_EPSILON = 0.0001f; // Token: 0x0400012A RID: 298 private static Vector3 tv1; // Token: 0x0400012B RID: 299 private static Vector3 tv2; // Token: 0x0400012C RID: 300 private static Vector3 tv3; // Token: 0x0400012D RID: 301 private static Vector3 tv4; } }