BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Properties | List of all members
BrawlLib.Internal.Vector2 Struct Reference
Inheritance diagram for BrawlLib.Internal.Vector2:

Public Member Functions

 Vector2 (float x, float y)
 
 Vector2 (float s)
 
float Dot (Vector2 v)
 
void Clamp (float min, float max)
 
void Min (Vector2 v)
 
void Min (float f)
 
void Max (Vector2 v)
 
void Max (float f)
 
float DistanceTo (Vector2 v)
 
override string ToString ()
 
bool Contained (Vector2 start, Vector2 end, float expansion)
 
float TrueDistance (Vector2 p)
 
void RemapToRange (float min, float max)
 
Vector2 RemappedToRange (float min, float max)
 
override int GetHashCode ()
 
override bool Equals (object obj)
 
int CompareTo (object obj)
 

Static Public Member Functions

static Vector2 operator- (Vector2 v)
 
static Vector2 operator+ (Vector2 v1, Vector2 v2)
 
static Vector2 operator- (Vector2 v1, Vector2 v2)
 
static Vector2 operator- (Vector2 v1, float f)
 
static Vector2 operator* (Vector2 v1, Vector2 v2)
 
static Vector2 operator* (Vector2 v1, float s)
 
static Vector2 operator* (float s, Vector2 v1)
 
static Vector2 operator/ (Vector2 v1, Vector2 v2)
 
static Vector2 operator/ (Vector2 v1, float s)
 
static Vector2 operator+ (Vector2 v1, Vector3 v2)
 
static Vector2 operator+ (Vector3 v1, Vector2 v2)
 
static bool operator== (Vector2 v1, Vector2 v2)
 
static bool operator<= (Vector2 v1, Vector2 v2)
 
static bool operator>= (Vector2 v1, Vector2 v2)
 
static bool operator!= (Vector2 v1, Vector2 v2)
 
static float Dot (Vector2 v1, Vector2 v2)
 
static Vector2 Clamp (Vector2 v1, float min, float max)
 
static Vector2 Min (Vector2 v1, Vector2 v2)
 
static Vector2 Min (Vector2 v1, float f)
 
static Vector2 Max (Vector2 v1, Vector2 v2)
 
static Vector2 Max (Vector2 v1, float f)
 
static Vector2 Lerp (Vector2 v1, Vector2 v2, float median)
 
static operator Vector2 (Vector3 v)
 
static operator Vector3 (Vector2 v)
 
static operator PointF (Vector2 v)
 
static operator Vector2 (PointF v)
 
static operator Point (Vector2 v)
 
static operator Vector2 (Point v)
 
static Vector2 Truncate (Vector2 v)
 
static bool Contained (Vector2 point, Vector2 start, Vector2 end, float expansion)
 

Public Attributes

float _x
 
float _y
 

Properties

float X [get, set]
 
float Y [get, set]
 

Constructor & Destructor Documentation

◆ Vector2() [1/2]

BrawlLib.Internal.Vector2.Vector2 ( float  x,
float  y 
)
inline
25 {
26 _x = x;
27 _y = y;
28 }
float _y
Definition: Vector2.cs:17
float _x
Definition: Vector2.cs:11

◆ Vector2() [2/2]

BrawlLib.Internal.Vector2.Vector2 ( float  s)
inline
31 {
32 _x = s;
33 _y = s;
34 }

Member Function Documentation

◆ Clamp() [1/2]

void BrawlLib.Internal.Vector2.Clamp ( float  min,
float  max 
)
inline
128 {
129 Max(min);
130 Min(max);
131 }
static Vector2 Max(Vector2 v1, Vector2 v2)
Definition: Vector2.cs:162
static Vector2 Min(Vector2 v1, Vector2 v2)
Definition: Vector2.cs:133

◆ Clamp() [2/2]

static Vector2 BrawlLib.Internal.Vector2.Clamp ( Vector2  v1,
float  min,
float  max 
)
inlinestatic
122 {
123 v1.Clamp(min, max);
124 return v1;
125 }

◆ CompareTo()

int BrawlLib.Internal.Vector2.CompareTo ( object  obj)
inline
324 {
325 if (obj is Vector2)
326 {
327 Vector2 o = (Vector2) obj;
328 if (_x > o._x)
329 {
330 return 1;
331 }
332
333 if (_x < o._x)
334 {
335 return -1;
336 }
337
338 if (_y > o._y)
339 {
340 return 1;
341 }
342
343 if (_y < o._y)
344 {
345 return -1;
346 }
347
348 return 0;
349 }
350
351 return 1;
352 }

◆ Contained() [1/2]

static bool BrawlLib.Internal.Vector2.Contained ( Vector2  point,
Vector2  start,
Vector2  end,
float  expansion 
)
inlinestatic
253 {
254 float* sPtr = (float*) &point;
255 float* s1 = (float*) &start, s2 = (float*) &end;
256 float* temp;
257 for (int i = 0; i < 2; i++)
258 {
259 if (s1[i] > s2[i])
260 {
261 temp = s1;
262 s1 = s2;
263 s2 = temp;
264 }
265
266 if (sPtr[i] < s1[i] - expansion || sPtr[i] > s2[i] + expansion)
267 {
268 return false;
269 }
270 }
271
272 return true;
273 }

◆ Contained() [2/2]

bool BrawlLib.Internal.Vector2.Contained ( Vector2  start,
Vector2  end,
float  expansion 
)
inline
248 {
249 return Contained(this, start, end, expansion);
250 }
bool Contained(Vector2 start, Vector2 end, float expansion)
Definition: Vector2.cs:247

◆ DistanceTo()

float BrawlLib.Internal.Vector2.DistanceTo ( Vector2  v)
inline
192 {
193 Vector2 v1 = this - v;
194 return Dot(v1, v1);
195 }
static float Dot(Vector2 v1, Vector2 v2)
Definition: Vector2.cs:111

◆ Dot() [1/2]

float BrawlLib.Internal.Vector2.Dot ( Vector2  v)
inline
117 {
118 return _x * v._x + _y * v._y;
119 }

◆ Dot() [2/2]

static float BrawlLib.Internal.Vector2.Dot ( Vector2  v1,
Vector2  v2 
)
inlinestatic
112 {
113 return v1._x * v2._x + v1._y * v2._y;
114 }

◆ Equals()

override bool BrawlLib.Internal.Vector2.Equals ( object  obj)
inline
314 {
315 if (obj is Vector2 vector2)
316 {
317 return this == vector2;
318 }
319
320 return false;
321 }

◆ GetHashCode()

override int BrawlLib.Internal.Vector2.GetHashCode ( )
inline
305 {
306 fixed (Vector2* p = &this)
307 {
308 int* p2 = (int*) p;
309 return p2[0] ^ p2[1];
310 }
311 }

◆ Lerp()

static Vector2 BrawlLib.Internal.Vector2.Lerp ( Vector2  v1,
Vector2  v2,
float  median 
)
inlinestatic
198 {
199 return v1 * median + v2 * (1.0f - median);
200 }

◆ Max() [1/4]

void BrawlLib.Internal.Vector2.Max ( float  f)
inline
186 {
187 _x = Math.Max(_x, f);
188 _y = Math.Max(_y, f);
189 }

◆ Max() [2/4]

void BrawlLib.Internal.Vector2.Max ( Vector2  v)
inline
173 {
174 if (_x < v._x)
175 {
176 _x = v._x;
177 }
178
179 if (_y < v._y)
180 {
181 _y = v._y;
182 }
183 }

◆ Max() [3/4]

static Vector2 BrawlLib.Internal.Vector2.Max ( Vector2  v1,
float  f 
)
inlinestatic
168 {
169 return new Vector2(Math.Max(v1._x, f), Math.Max(v1._y, f));
170 }

◆ Max() [4/4]

static Vector2 BrawlLib.Internal.Vector2.Max ( Vector2  v1,
Vector2  v2 
)
inlinestatic
163 {
164 return new Vector2(Math.Max(v1._x, v2._x), Math.Max(v1._y, v2._y));
165 }

◆ Min() [1/4]

void BrawlLib.Internal.Vector2.Min ( float  f)
inline
157 {
158 _x = Math.Min(_x, f);
159 _y = Math.Min(_y, f);
160 }

◆ Min() [2/4]

void BrawlLib.Internal.Vector2.Min ( Vector2  v)
inline
144 {
145 if (_x > v._x)
146 {
147 _x = v._x;
148 }
149
150 if (_y > v._y)
151 {
152 _y = v._y;
153 }
154 }

◆ Min() [3/4]

static Vector2 BrawlLib.Internal.Vector2.Min ( Vector2  v1,
float  f 
)
inlinestatic
139 {
140 return new Vector2(Math.Min(v1._x, f), Math.Min(v1._y, f));
141 }

◆ Min() [4/4]

static Vector2 BrawlLib.Internal.Vector2.Min ( Vector2  v1,
Vector2  v2 
)
inlinestatic
134 {
135 return new Vector2(Math.Min(v1._x, v2._x), Math.Min(v1._y, v2._y));
136 }

◆ operator Point()

static BrawlLib.Internal.Vector2.operator Point ( Vector2  v)
inlineexplicitstatic
223 {
224 Vector2 t = Truncate(v);
225 return new Point((int) t._x, (int) t._y);
226 }
static Vector2 Truncate(Vector2 v)
Definition: Vector2.cs:233

◆ operator PointF()

static BrawlLib.Internal.Vector2.operator PointF ( Vector2  v)
inlineexplicitstatic
213 {
214 return new PointF(v._x, v._y);
215 }

◆ operator Vector2() [1/3]

static BrawlLib.Internal.Vector2.operator Vector2 ( Point  v)
inlineexplicitstatic
229 {
230 return new Vector2(v.X, v.Y);
231 }

◆ operator Vector2() [2/3]

static BrawlLib.Internal.Vector2.operator Vector2 ( PointF  v)
inlineexplicitstatic
218 {
219 return new Vector2(v.X, v.Y);
220 }

◆ operator Vector2() [3/3]

static BrawlLib.Internal.Vector2.operator Vector2 ( Vector3  v)
inlineexplicitstatic
203 {
204 return new Vector2(v._x, v._y);
205 }

◆ operator Vector3()

static BrawlLib.Internal.Vector2.operator Vector3 ( Vector2  v)
inlineexplicitstatic
208 {
209 return new Vector3(v._x, v._y, 0.0f);
210 }

◆ operator!=()

static bool BrawlLib.Internal.Vector2.operator!= ( Vector2  v1,
Vector2  v2 
)
inlinestatic
107 {
108 return v1._x != v2._x || v1._y != v2._y;
109 }

◆ operator*() [1/3]

static Vector2 BrawlLib.Internal.Vector2.operator* ( float  s,
Vector2  v1 
)
inlinestatic
67 {
68 return new Vector2(v1._x * s, v1._y * s);
69 }

◆ operator*() [2/3]

static Vector2 BrawlLib.Internal.Vector2.operator* ( Vector2  v1,
float  s 
)
inlinestatic
62 {
63 return new Vector2(v1._x * s, v1._y * s);
64 }

◆ operator*() [3/3]

static Vector2 BrawlLib.Internal.Vector2.operator* ( Vector2  v1,
Vector2  v2 
)
inlinestatic
57 {
58 return new Vector2(v1._x * v2._x, v1._y * v2._y);
59 }

◆ operator+() [1/3]

static Vector2 BrawlLib.Internal.Vector2.operator+ ( Vector2  v1,
Vector2  v2 
)
inlinestatic
42 {
43 return new Vector2(v1._x + v2._x, v1._y + v2._y);
44 }

◆ operator+() [2/3]

static Vector2 BrawlLib.Internal.Vector2.operator+ ( Vector2  v1,
Vector3  v2 
)
inlinestatic
82 {
83 return new Vector2(v1._x + v2._x, v1._y + v2._y);
84 }

◆ operator+() [3/3]

static Vector2 BrawlLib.Internal.Vector2.operator+ ( Vector3  v1,
Vector2  v2 
)
inlinestatic
87 {
88 return new Vector2(v1._x + v2._x, v1._y + v2._y);
89 }

◆ operator-() [1/3]

static Vector2 BrawlLib.Internal.Vector2.operator- ( Vector2  v)
inlinestatic
37 {
38 return new Vector2(-v._x, -v._y);
39 }

◆ operator-() [2/3]

static Vector2 BrawlLib.Internal.Vector2.operator- ( Vector2  v1,
float  f 
)
inlinestatic
52 {
53 return new Vector2(v1._x - f, v1._y - f);
54 }

◆ operator-() [3/3]

static Vector2 BrawlLib.Internal.Vector2.operator- ( Vector2  v1,
Vector2  v2 
)
inlinestatic
47 {
48 return new Vector2(v1._x - v2._x, v1._y - v2._y);
49 }

◆ operator/() [1/2]

static Vector2 BrawlLib.Internal.Vector2.operator/ ( Vector2  v1,
float  s 
)
inlinestatic
77 {
78 return new Vector2(v1._x / s, v1._y / s);
79 }

◆ operator/() [2/2]

static Vector2 BrawlLib.Internal.Vector2.operator/ ( Vector2  v1,
Vector2  v2 
)
inlinestatic
72 {
73 return new Vector2(v1._x / v2._x, v1._y / v2._y);
74 }

◆ operator<=()

static bool BrawlLib.Internal.Vector2.operator<= ( Vector2  v1,
Vector2  v2 
)
inlinestatic
97 {
98 return v1._x <= v2._x && v1._y <= v2._y;
99 }

◆ operator==()

static bool BrawlLib.Internal.Vector2.operator== ( Vector2  v1,
Vector2  v2 
)
inlinestatic
92 {
93 return v1._x == v2._x && v1._y == v2._y;
94 }

◆ operator>=()

static bool BrawlLib.Internal.Vector2.operator>= ( Vector2  v1,
Vector2  v2 
)
inlinestatic
102 {
103 return v1._x >= v2._x && v1._y >= v2._y;
104 }

◆ RemappedToRange()

Vector2 BrawlLib.Internal.Vector2.RemappedToRange ( float  min,
float  max 
)
inline
300 {
301 return new Vector2(_x.RemapToRange(min, max), _y.RemapToRange(min, max));
302 }

◆ RemapToRange()

void BrawlLib.Internal.Vector2.RemapToRange ( float  min,
float  max 
)
inline
294 {
295 _x = _x.RemapToRange(min, max);
296 _y = _y.RemapToRange(min, max);
297 }

◆ ToString()

override string BrawlLib.Internal.Vector2.ToString ( )
inline
241 {
242 return CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(",")
243 ? $"({_x} {_y})"
244 : $"({_x},{_y})";
245 }

◆ TrueDistance()

float BrawlLib.Internal.Vector2.TrueDistance ( Vector2  p)
inline
276 {
277 float lenX = Math.Abs(p._x - _x);
278 float lenY = Math.Abs(p._y - _y);
279
280 if (lenX == 0.0f)
281 {
282 return lenY;
283 }
284
285 if (lenY == 0.0f)
286 {
287 return lenX;
288 }
289
290 return (float) (lenX / Math.Cos(Math.Atan(lenY / lenX)));
291 }

◆ Truncate()

static Vector2 BrawlLib.Internal.Vector2.Truncate ( Vector2  v)
inlinestatic
234 {
235 return new Vector2(
236 v._x > 0.0f ? (float) Math.Floor(v._x) : (float) Math.Ceiling(v._x),
237 v._y > 0.0f ? (float) Math.Floor(v._y) : (float) Math.Ceiling(v._y));
238 }

Member Data Documentation

◆ _x

float BrawlLib.Internal.Vector2._x

◆ _y

float BrawlLib.Internal.Vector2._y

Property Documentation

◆ X

float BrawlLib.Internal.Vector2.X
getset
13 {
14 get => _x;
15 set => _x = value;
16 }

◆ Y

float BrawlLib.Internal.Vector2.Y
getset
19 {
20 get => _y;
21 set => _y = value;
22 }

The documentation for this struct was generated from the following file: