-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathVector4Node.cs
More file actions
351 lines (316 loc) · 12.2 KB
/
Vector4Node.cs
File metadata and controls
351 lines (316 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Numerics;
namespace CommunityToolkit.WinUI.Animations.Expressions;
// Ignore warning: 'Vector4Node' defines operator == or operator != but does not override Object.Equals(object o) && Object.GetHashCode()
#pragma warning disable CS0660, CS0661
/// <summary>
/// Class Vector4Node. This class cannot be inherited.
/// </summary>
/// <seealso cref="CommunityToolkit.WinUI.Animations.Expressions.ExpressionNode" />
public sealed partial class Vector4Node : ExpressionNode
{
/// <summary>
/// Initializes a new instance of the <see cref="Vector4Node"/> class.
/// </summary>
internal Vector4Node()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Vector4Node"/> class.
/// </summary>
/// <param name="value">The value.</param>
internal Vector4Node(Vector4 value)
{
_value = value;
NodeType = ExpressionNodeType.ConstantValue;
}
/// <summary>
/// Initializes a new instance of the <see cref="Vector4Node"/> class.
/// </summary>
/// <param name="paramName">Name of the parameter.</param>
internal Vector4Node(string paramName)
{
ParamName = paramName;
NodeType = ExpressionNodeType.ConstantParameter;
}
/// <summary>
/// Initializes a new instance of the <see cref="Vector4Node"/> class.
/// </summary>
/// <param name="paramName">Name of the parameter.</param>
/// <param name="value">The value.</param>
internal Vector4Node(string paramName, Vector4 value)
{
ParamName = paramName;
_value = value;
NodeType = ExpressionNodeType.ConstantParameter;
SetVector4Parameter(paramName, value);
}
/// <summary>
/// Performs an implicit conversion from <see cref="Vector4"/> to <see cref="Vector4Node"/>.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator Vector4Node(Vector4 value)
{
return new Vector4Node(value);
}
/// <summary>
/// Implements the + operator.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>The result of the operator.</returns>
public static Vector4Node operator +(Vector4Node left, Vector4Node right)
{
return ExpressionFunctions.Function<Vector4Node>(ExpressionNodeType.Add, left, right);
}
/// <summary>
/// Implements the - operator.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>The result of the operator.</returns>
public static Vector4Node operator -(Vector4Node left, Vector4Node right)
{
return ExpressionFunctions.Function<Vector4Node>(ExpressionNodeType.Subtract, left, right);
}
/// <summary>
/// Implements the - operator.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The result of the operator.</returns>
public static Vector4Node operator -(Vector4Node value)
{
return ExpressionFunctions.Function<Vector4Node>(ExpressionNodeType.Negate, value);
}
/// <summary>
/// Implements the * operator.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>The result of the operator.</returns>
public static Vector4Node operator *(Vector4Node left, ScalarNode right)
{
return ExpressionFunctions.Function<Vector4Node>(ExpressionNodeType.Multiply, left, right);
}
/// <summary>
/// Implements the * operator.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>The result of the operator.</returns>
public static Vector4Node operator *(Vector4Node left, Vector4Node right)
{
return ExpressionFunctions.Function<Vector4Node>(ExpressionNodeType.Multiply, left, right);
}
/// <summary>
/// Implements the / operator.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>The result of the operator.</returns>
public static Vector4Node operator /(Vector4Node left, Vector4Node right)
{
return ExpressionFunctions.Function<Vector4Node>(ExpressionNodeType.Divide, left, right);
}
/// <summary>
/// Implements the % operator.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>The result of the operator.</returns>
public static Vector4Node operator %(Vector4Node left, Vector4Node right)
{
return ExpressionFunctions.Function<Vector4Node>(ExpressionNodeType.Modulus, left, right);
}
/// <summary>
/// Implements the == operator.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>The result of the operator.</returns>
public static BooleanNode operator ==(Vector4Node left, Vector4Node right)
{
return ExpressionFunctions.Function<BooleanNode>(ExpressionNodeType.Equals, left, right);
}
/// <summary>
/// Implements the != operator.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>The result of the operator.</returns>
public static BooleanNode operator !=(Vector4Node left, Vector4Node right)
{
return ExpressionFunctions.Function<BooleanNode>(ExpressionNodeType.NotEquals, left, right);
}
/// <summary>
/// Enum Subchannel
/// </summary>
public enum Subchannel
{
/// <summary>
/// The x channel
/// </summary>
X,
/// <summary>
/// The y channel
/// </summary>
Y,
/// <summary>
/// The z channel
/// </summary>
Z,
/// <summary>
/// The w channel
/// </summary>
W
}
/// <summary>
/// Gets the x channel.
/// </summary>
/// <value>The x.</value>
public ScalarNode X
{
get { return GetSubchannels(Subchannel.X); }
}
/// <summary>
/// Gets the y channel.
/// </summary>
/// <value>The y.</value>
public ScalarNode Y
{
get { return GetSubchannels(Subchannel.Y); }
}
/// <summary>
/// Gets the z channel.
/// </summary>
/// <value>The z.</value>
public ScalarNode Z
{
get { return GetSubchannels(Subchannel.Z); }
}
/// <summary>
/// Gets the w channel.
/// </summary>
/// <value>The w.</value>
public ScalarNode W
{
get { return GetSubchannels(Subchannel.W); }
}
/// <summary>
/// Gets the x and y channels.
/// </summary>
/// <value>The xy.</value>
public Vector2Node XY
{
get { return GetSubchannels(Subchannel.X, Subchannel.Y); }
}
/// <summary>
/// Gets the x, y, and z channels.
/// </summary>
/// <value>The xyz.</value>
public Vector3Node XYZ
{
get { return GetSubchannels(Subchannel.X, Subchannel.Y, Subchannel.Z); }
}
/// <summary>
/// Create a new type by re-arranging the Vector subchannels.
/// </summary>
/// <param name="s">The subchannel.</param>
/// <returns>ScalarNode</returns>
public ScalarNode GetSubchannels(Subchannel s)
{
return SubchannelsInternal<ScalarNode>(s.ToString());
}
/// <summary>
/// Create a new type by re-arranging the Vector subchannels.
/// </summary>
/// <param name="s1">The first subchannel.</param>
/// <param name="s2">The second subchannel.</param>
/// <returns>Vector2Node</returns>
public Vector2Node GetSubchannels(Subchannel s1, Subchannel s2)
{
return SubchannelsInternal<Vector2Node>(s1.ToString(), s2.ToString());
}
/// <summary>
/// Create a new type by re-arranging the Vector subchannels.
/// </summary>
/// <param name="s1">The first subchannel.</param>
/// <param name="s2">The second subchannel.</param>
/// <param name="s3">The third subchannel.</param>
/// <returns>Vector3Node</returns>
public Vector3Node GetSubchannels(Subchannel s1, Subchannel s2, Subchannel s3)
{
return SubchannelsInternal<Vector3Node>(s1.ToString(), s2.ToString(), s3.ToString());
}
/// <summary>
/// Create a new type by re-arranging the Vector subchannels.
/// </summary>
/// <param name="s1">The first subchannel.</param>
/// <param name="s2">The second subchannel.</param>
/// <param name="s3">The third subchannel.</param>
/// <param name="s4">The fourth subchannel.</param>
/// <returns>Vector4Node</returns>
public Vector4Node GetSubchannels(Subchannel s1, Subchannel s2, Subchannel s3, Subchannel s4)
{
return SubchannelsInternal<Vector4Node>(s1.ToString(), s2.ToString(), s3.ToString(), s4.ToString());
}
/// <summary>
/// Create a new type by re-arranging the Vector subchannels.
/// </summary>
/// <param name="s1">The first subchannel.</param>
/// <param name="s2">The second subchannel.</param>
/// <param name="s3">The third subchannel.</param>
/// <param name="s4">The fourth subchannel.</param>
/// <param name="s5">The fifth subchannel.</param>
/// <param name="s6">The sixth subchannel.</param>
/// <returns>Matrix3x2Node</returns>
public Matrix3x2Node GetSubchannels(Subchannel s1, Subchannel s2, Subchannel s3, Subchannel s4, Subchannel s5, Subchannel s6)
{
return SubchannelsInternal<Matrix3x2Node>(s1.ToString(), s2.ToString(), s3.ToString(), s4.ToString(), s5.ToString(), s6.ToString());
}
/// <summary>
/// Create a new type by re-arranging the Vector subchannels.
/// </summary>
/// <param name="s1">The first subchannel.</param>
/// <param name="s2">The second subchannel.</param>
/// <param name="s3">The third subchannel.</param>
/// <param name="s4">The fourth subchannel.</param>
/// <param name="s5">The fifth subchannel.</param>
/// <param name="s6">The sixth subchannel.</param>
/// <param name="s7">The seventh subchannel.</param>
/// <param name="s8">The eighth subchannel.</param>
/// <param name="s9">The ninth subchannel.</param>
/// <param name="s10">The tenth subchannel.</param>
/// <param name="s11">The eleventh subchannel.</param>
/// <param name="s12">The twelfth subchannel.</param>
/// <param name="s13">The thirteenth subchannel.</param>
/// <param name="s14">The fourteenth subchannel.</param>
/// <param name="s15">The fifteenth subchannel.</param>
/// <param name="s16">The sixteenth subchannel.</param>
/// <returns>Matrix4x4Node</returns>
#pragma warning disable SA1117 // Parameters must be on same line or separate lines
public Matrix4x4Node GetSubchannels(Subchannel s1, Subchannel s2, Subchannel s3, Subchannel s4,
Subchannel s5, Subchannel s6, Subchannel s7, Subchannel s8,
Subchannel s9, Subchannel s10, Subchannel s11, Subchannel s12,
Subchannel s13, Subchannel s14, Subchannel s15, Subchannel s16)
{
return SubchannelsInternal<Matrix4x4Node>(s1.ToString(), s2.ToString(), s3.ToString(), s4.ToString(),
s5.ToString(), s6.ToString(), s7.ToString(), s8.ToString(),
s9.ToString(), s10.ToString(), s11.ToString(), s12.ToString(),
s13.ToString(), s14.ToString(), s15.ToString(), s16.ToString());
}
#pragma warning restore SA1117 // Parameters must be on same line or separate lines
/// <summary>
/// Gets the value.
/// </summary>
/// <returns>System.String.</returns>
protected internal override string GetValue()
{
return $"Vector4({_value.X.ToCompositionString()},{_value.Y.ToCompositionString()},{_value.Z.ToCompositionString()},{_value.W.ToCompositionString()})";
}
private Vector4 _value;
}
#pragma warning restore CS0660, CS0661