3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6 using System.Collections.Generic;
7 using System.Threading.Tasks;
9 namespace Tizen.NUI.Devel.Tests
11 using tlog = Tizen.Log;
14 [Description("public/Common/Rotation")]
15 public class PublicRotationTest
17 private const string tag = "NUITEST";
19 private Vector3 MyCross(Vector3 vector1, Vector3 vector2)
21 return new Vector3((vector1.Y * vector2.Z) - (vector1.Z * vector2.Y),
22 (vector1.Z * vector2.X) - (vector1.X * vector2.Z),
23 (vector1.X * vector2.Y) - (vector1.Y * vector2.X));
26 private float MyDot(Vector3 vector1, Vector3 vector2)
28 return vector1.X * vector2.X + vector1.Y * vector2.Y + vector1.Z * vector2.Z; ;
34 tlog.Info(tag, "Init() is called!");
40 tlog.Info(tag, "Destroy() is called!");
45 [Description("Rotation Addition.")]
46 [Property("SPEC", "Tizen.NUI.Rotation.+ M")]
47 [Property("SPEC_URL", "-")]
48 [Property("CRITERIA", "MR")]
49 [Property("AUTHOR", "guowei.wang@samsung.com")]
50 public void RotationAddition()
52 tlog.Debug(tag, $"RotationAddition START");
54 var testingTarget = new Rotation(new Radian(new Degree(180.0f)), new Vector3(1.0f, 0.0f, 0.0f));
55 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
56 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
58 using (Rotation rotation = new Rotation(new Radian(new Degree(180.0f)), new Vector3(1.0f, 0.0f, 0.0f)))
60 var result = testingTarget + rotation;
62 Radian radian = new Radian(0.0f);
63 Vector3 axis = new Vector3();
64 result.GetAxisAngle(axis, radian);
66 Assert.AreEqual(2.0f, axis.X, "Addition function does not work, Vector3.X value is not correct");
67 Assert.AreEqual(0.0f, axis.Y, "Addition function does not work, Vector3.Y value is not correct");
68 Assert.AreEqual(0.0f, axis.Z, "Addition function does not work, Vector3.Z value is not correct");
71 testingTarget.Dispose();
72 tlog.Debug(tag, $"RotationAddition END (OK)");
77 [Description("Rotation Subtraction.")]
78 [Property("SPEC", "Tizen.NUI.Rotation.- M")]
79 [Property("SPEC_URL", "-")]
80 [Property("CRITERIA", "MR")]
81 [Property("AUTHOR", "guowei.wang@samsung.com")]
82 public void RotationSubtraction()
84 tlog.Debug(tag, $"RotationSubtraction START");
86 var testingTarget = new Rotation(new Radian(new Degree(180.0f)), new Vector3(0.0f, 1.0f, 0.0f));
87 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
88 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
90 using (Rotation rotation = new Rotation(new Radian(new Degree(180.0f)), new Vector3(0.0f, 1.0f, 0.0f)))
92 var result = testingTarget - rotation;
94 Radian radian = new Radian(0.0f);
95 Vector3 axis = new Vector3();
96 result.GetAxisAngle(axis, radian);
98 Assert.AreEqual(0.0f, axis.X, "Subtraction function does not work, Vector3.X value is not correct");
99 Assert.AreEqual(0.0f, axis.Y, "Subtraction function does not work, Vector3.Y value is not correct");
100 Assert.AreEqual(0.0f, axis.Z, "Subtraction function does not work, Vector3.Z value is not correct");
103 testingTarget.Dispose();
104 tlog.Debug(tag, $"RotationSubtraction END (OK)");
109 [Description("Rotation UnaryNegation.")]
110 [Property("SPEC", "Tizen.NUI.Rotation.UnaryNegation M")]
111 [Property("SPEC_URL", "-")]
112 [Property("CRITERIA", "MR")]
113 [Property("AUTHOR", "guowei.wang@samsung.com")]
114 public void RotationUnaryNegation()
116 tlog.Debug(tag, $"RotationUnaryNegation START");
118 Rotation testingTarget = null;
119 using (Rotation rotation = new Rotation(new Radian(new Degree(180.0f)), new Vector3(0.0f, 1.0f, 0.0f)))
121 testingTarget = -rotation;
123 Radian radian = new Radian(0.0f);
124 Vector3 axis = new Vector3();
125 testingTarget.GetAxisAngle(axis, radian);
127 Assert.AreEqual(0.0f, axis.X, "UnaryNegation function does not work, Vector3.X value is not correct");
128 Assert.AreEqual(-1.0f, axis.Y, "UnaryNegation function does not work, Vector3.Y value is not correct");
129 Assert.AreEqual(0.0f, axis.Z, "UnaryNegation function does not work, Vector3.Z value is not correct");
133 testingTarget.Dispose();
134 tlog.Debug(tag, $"RotationUnaryNegation END (OK)");
139 [Description("Rotation Multiply. By Rotation.")]
140 [Property("SPEC", "Tizen.NUI.Rotation.* M")]
141 [Property("SPEC_URL", "-")]
142 [Property("CRITERIA", "MR")]
143 [Property("COVPARAM", "Rotation, Rotation")]
144 [Property("AUTHOR", "guowei.wang@samsung.com")]
145 public void RotationMultiplyByRotation()
147 tlog.Debug(tag, $"RotationMultiplyByRotation START");
149 using (Vector3 vector = new Vector3(0.0f, 0.0f, 0.0f))
151 Rotation rotation = new Rotation(new Radian(MyDot(vector, vector)), MyCross(vector, vector));
153 Radian radian = new Radian(0.0f);
154 Vector3 axis = new Vector3();
155 rotation.GetAxisAngle(axis, radian);
157 var testingTarget = new Rotation(new Radian(0.0f), vector);
158 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
159 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
161 using (Rotation multiplier = new Rotation(new Radian(0.0f), vector))
163 var result = testingTarget * multiplier;
165 Radian radian2 = new Radian(0.0f);
166 Vector3 axis2 = new Vector3();
167 result.GetAxisAngle(axis2, radian2);
169 Assert.AreEqual(float.Parse(axis2.X.ToString("F2")), float.Parse(axis.X.ToString("F2")), "Vector3 got from Multiply is not correct, X value is not correct");
170 Assert.AreEqual(float.Parse(axis2.Y.ToString("F2")), float.Parse(axis.Y.ToString("F2")), "Vector3 got from Multiply is not correct, Y value is not correct");
171 Assert.AreEqual(float.Parse(axis2.Z.ToString("F2")), float.Parse(axis.Z.ToString("F2")), "Vector3 got from Multiply is not correct, Z value is not correct");
175 testingTarget.Dispose();
178 tlog.Debug(tag, $"RotationMultiplyByRotation END (OK)");
183 [Description("Rotation Multiply. By Vector3.")]
184 [Property("SPEC", "Tizen.NUI.Rotation.* M")]
185 [Property("SPEC_URL", "-")]
186 [Property("CRITERIA", "MR")]
187 [Property("AUTHOR", "guowei.wang@samsung.com")]
188 public void RotationMultiplyByVector3()
190 tlog.Debug(tag, $"RotationMultiplyByVector3 START");
192 using (Vector3 vector = new Vector3(0.0f, 0.0f, 0.0f))
194 using (Rotation rotation = new Rotation(new Radian(0.0f), Vector3.Zero))
196 Rotation rotation1 = rotation;
198 Rotation rotation2 = new Rotation(new Radian(0.0f), vector);
200 var result = (rotation * rotation2) * rotation1;
202 Radian radian = new Radian(0.0f);
203 Vector3 axis = new Vector3();
204 result.GetAxisAngle(axis, radian);
206 var testingTarget = rotation * vector;
207 Assert.IsNotNull(testingTarget, "Can't create success object Vector3");
208 Assert.IsInstanceOf<Vector3>(testingTarget, "Should return Vector3 instance.");
210 Assert.AreEqual(testingTarget.X, float.Parse(axis.X.ToString("F2")), "Vector3 got from Multiply is not correct, X value is not correct");
211 Assert.AreEqual(testingTarget.Y, float.Parse(axis.Y.ToString("F2")), "Vector3 got from Multiply is not correct, Y value is not correct");
212 Assert.AreEqual(testingTarget.Z, float.Parse(axis.Z.ToString("F2")), "Vector3 got from Multiply is not correct, Z value is not correct");
219 tlog.Debug(tag, $"RotationMultiplyByVector3 END (OK)");
224 [Description("Rotation Multiply. By Float.")]
225 [Property("SPEC", "Tizen.NUI.Rotation.* M")]
226 [Property("SPEC_URL", "-")]
227 [Property("CRITERIA", "MR")]
228 [Property("AUTHOR", "guowei.wang@samsung.com")]
229 public void RotationMultiplyByFloat()
231 tlog.Debug(tag, $"RotationMultiplyByFloat START");
233 var testingTarget = new Rotation(new Radian(new Degree(180)), new Vector3(1.0f, 0.0f, 0.0f));
234 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
235 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
237 var result = testingTarget * 2.0f;
239 Radian radian = new Radian(0.0f);
240 Vector3 axis = new Vector3();
241 result.GetAxisAngle(axis, radian);
243 Assert.AreEqual(2.0f, float.Parse(axis.X.ToString("F2")), "Vector3 got from Multiply is not correct, X value is not correct");
244 Assert.AreEqual(0.0f, float.Parse(axis.Y.ToString("F2")), "Vector3 got from Multiply is not correct, Y value is not correct");
245 Assert.AreEqual(0.0f, float.Parse(axis.Z.ToString("F2")), "Vector3 got from Multiply is not correct, Z value is not correct");
247 testingTarget.Dispose();
248 tlog.Debug(tag, $"RotationMultiplyByFloat END (OK)");
253 [Description("Rotation Division. By Rotation.")]
254 [Property("SPEC", "Tizen.NUI.Rotation./ M")]
255 [Property("SPEC_URL", "-")]
256 [Property("CRITERIA", "MR")]
257 [Property("AUTHOR", "guowei.wang@samsung.com")]
258 public void RotationDivisionByRotation()
260 tlog.Debug(tag, $"RotationDivisionByRotation START");
262 var testingTarget = new Rotation(new Radian(2.35551f), new Vector3(0.0f, 0.0f, 1.00027f));
263 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
264 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
266 using (Rotation rotation = new Rotation(new Radian(3.14159f), new Vector3(0.609f, 0.0f, 0.793f)))
268 var result = testingTarget / rotation;
270 Radian radian = new Radian(0.0f);
271 Vector3 axis = new Vector3();
272 result.GetAxisAngle(axis, radian);
274 Assert.AreEqual(-0.34f, float.Parse(axis.X.ToString("F2")), "Should be equal!");
275 Assert.AreEqual(-0.83f, float.Parse(axis.Y.ToString("F2")), "Should be equal!");
276 Assert.AreEqual(-0.45f, float.Parse(axis.Z.ToString("F2")), "Should be equal!");
279 testingTarget.Dispose();
280 tlog.Debug(tag, $"RotationDivisionByRotation END (OK)");
285 [Description("Rotation Division.")]
286 [Property("SPEC", "Tizen.NUI.Rotation./ M")]
287 [Property("SPEC_URL", "-")]
288 [Property("CRITERIA", "MR")]
289 [Property("AUTHOR", "guowei.wang@samsung.com")]
290 public void RotationDivisionByFloat()
292 tlog.Debug(tag, $"RotationDivisionByFloat START");
294 var testingTarget = new Rotation(new Radian(new Degree(180.0f)), new Vector3(0.0f, 1.0f, 0.0f));
295 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
296 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
298 var result = testingTarget / 2.0f;
299 Radian radian = new Radian(0.0f);
300 Vector3 axis = new Vector3();
302 result.GetAxisAngle(axis, radian);
303 Assert.AreEqual(0.0f, axis.X, "Division function does not work, Vector3.X value is not correct");
304 Assert.AreEqual(0.5f, axis.Y, "Division function does not work, Vector3.Y value is not correct");
305 Assert.AreEqual(0.0f, axis.Z, "Division function does not work, Vector3.Z value is not correct");
307 testingTarget.Dispose();
308 tlog.Debug(tag, $"RotationDivisionByFloat END (OK)");
313 [Description("Rotation constructor.")]
314 [Property("SPEC", "Tizen.NUI.Rotation.Rotation C")]
315 [Property("SPEC_URL", "-")]
316 [Property("CRITERIA", "CONSTR")]
317 [Property("AUTHOR", "guowei.wang@samsung.com")]
318 public void RotationConstructor()
320 tlog.Debug(tag, $"RotationConstructor START");
322 var testingTarget = new Rotation();
323 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
324 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
326 testingTarget.Dispose();
327 tlog.Debug(tag, $"RotationConstructor END (OK)");
332 [Description("Rotation constructor. With Radian and Vector3.")]
333 [Property("SPEC", "Tizen.NUI.Rotation.Rotation C")]
334 [Property("SPEC_URL", "-")]
335 [Property("CRITERIA", "CONSTR")]
336 [Property("AUTHOR", "guowei.wang@samsung.com")]
337 public void RotationConstructorWithRadianAndVector3()
339 tlog.Debug(tag, $"RotationConstructorWithRadianAndVector3 START");
341 var testingTarget = new Rotation(new Radian(6.0f), new Vector3(1.0f, 2.0f, 3.0f));
342 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
343 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
345 Radian radian = new Radian(0.0f);
346 Vector3 axis = new Vector3();
347 testingTarget.GetAxisAngle(axis, radian);
349 Assert.AreEqual(0.27f, float.Parse(axis.X.ToString("F2")), "Vector3 parameter got from constructor is not correct, X value is not correct");
350 Assert.AreEqual(0.53f, float.Parse(axis.Y.ToString("F2")), "Vector3 parameter got from constructor is not correct, Y value is not correct");
351 Assert.AreEqual(0.80f, float.Parse(axis.Z.ToString("F2")), "Vector3 parameter got from constructor is not correct, Z value is not correct");
353 testingTarget.Dispose();
354 tlog.Debug(tag, $"RotationConstructorWithRadianAndVector3 END (OK)");
359 [Description("Rotation IDENTITY.")]
360 [Property("SPEC", "Tizen.NUI.Rotation.IDENTITY A")]
361 [Property("SPEC_URL", "-")]
362 [Property("CRITERIA", "PRO")]
363 [Property("AUTHOR", "guowei.wang@samsung.com")]
364 public void RotationIDENTITY()
366 tlog.Debug(tag, $"RotationIDENTITY START");
368 Rotation rotation = new Rotation(new Radian(0.0f), new Vector3(1.0f, 1.0f, 1.0f));
369 Radian radian = new Radian(0.0f);
370 Vector3 axis = new Vector3();
371 rotation.GetAxisAngle(axis, radian);
373 var testingTarget = Rotation.IDENTITY;
374 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
375 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
377 Radian radian2 = new Radian(0.0f);
378 Vector3 axis2 = new Vector3();
379 testingTarget.GetAxisAngle(axis2, radian2);
381 Assert.AreEqual(float.Parse(axis2.X.ToString("F2")), float.Parse(axis.X.ToString("F2")), "Vector3 got from IDENTITY is not correct, X value is not correct");
382 Assert.AreEqual(float.Parse(axis2.X.ToString("F2")), float.Parse(axis.Y.ToString("F2")), "Vector3 got from IDENTITY is not correct, Y value is not correct");
383 Assert.AreEqual(float.Parse(axis2.X.ToString("F2")), float.Parse(axis.Z.ToString("F2")), "Vector3 got from IDENTITY is not correct, Z value is not correct");
386 testingTarget.Dispose();
387 tlog.Debug(tag, $"RotationIDENTITY END (OK)");
392 [Description("Rotation IsIdentity.")]
393 [Property("SPEC", "Tizen.NUI.Rotation.IsIdentity M")]
394 [Property("SPEC_URL", "-")]
395 [Property("CRITERIA", "MR")]
396 [Property("AUTHOR", "guowei.wang@samsung.com")]
397 public void RotationIsIdentity()
399 tlog.Debug(tag, $"RotationIsIdentity START");
401 using (Rotation testingTarget = Rotation.IDENTITY)
403 Assert.IsTrue(testingTarget.IsIdentity(), "IsIdentity should return true!");
406 using (Rotation testingTarget = new Rotation(new Radian(90.0f), new Vector3(0.1f, 0.0f, 0.0f)))
408 Assert.IsFalse(testingTarget.IsIdentity(), "IsIdentity should return false!");
411 tlog.Debug(tag, $"RotationIsIdentity END (OK)");
416 [Description("Rotation GetAxisAngle.")]
417 [Property("SPEC", "Tizen.NUI.Rotation.GetAxisAngle M")]
418 [Property("SPEC_URL", "-")]
419 [Property("CRITERIA", "MR")]
420 [Property("AUTHOR", "guowei.wang@samsung.com")]
421 public void RotationGetAxisAngle()
423 tlog.Debug(tag, $"RotationGetAxisAngle START");
425 var testingTarget = new Rotation(new Radian(6.0f), new Vector3(1.0f, 2.0f, 3.0f));
426 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
427 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
429 Radian radian = new Radian(0.0f);
430 Vector3 axis = new Vector3();
431 testingTarget.GetAxisAngle(axis, radian);
433 Assert.AreEqual(0.27f, float.Parse(axis.X.ToString("F2")), "Vector3 got from GetAxisAngle is not correct, X value is not correct");
434 Assert.AreEqual(0.53f, float.Parse(axis.Y.ToString("F2")), "Vector3 got from GetAxisAngle is not correct, Y value is not correct");
435 Assert.AreEqual(0.80f, float.Parse(axis.Z.ToString("F2")), "Vector3 got from GetAxisAngle is not correct, Z value is not correct");
437 testingTarget.Dispose();
438 tlog.Debug(tag, $"RotationGetAxisAngle END (OK)");
443 [Description("Rotation Length.")]
444 [Property("SPEC", "Tizen.NUI.Rotation.Length M")]
445 [Property("SPEC_URL", "-")]
446 [Property("CRITERIA", "MR")]
447 [Property("AUTHOR", "guowei.wang@samsung.com")]
448 public void RotationLength()
450 tlog.Debug(tag, $"RotationLength START");
452 var testingTarget = new Rotation(new Radian(new Degree(90)), new Vector3(1.0f, 2.0f, 3.0f));
453 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
454 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
456 double a = Math.Sqrt(0.707f * 0.707f + 0.189f * 0.189f + 0.378f * 0.378f + 0.567f * 0.567f);
458 var result = testingTarget.Length();
459 Assert.AreEqual(float.Parse(a.ToString("F2")), float.Parse(result.ToString("F2")), "Length function return incorrect value");
461 testingTarget.Dispose();
462 tlog.Debug(tag, $"RotationLength END (OK)");
467 [Description("Rotation LengthSquared.")]
468 [Property("SPEC", "Tizen.NUI.Rotation.LengthSquared M")]
469 [Property("SPEC_URL", "-")]
470 [Property("CRITERIA", "MR")]
471 [Property("AUTHOR", "guowei.wang@samsung.com")]
472 public void RotationLengthSquared()
474 tlog.Debug(tag, $"RotationLengthSquared START");
476 var testingTarget = new Rotation(new Radian(new Degree(90)), new Vector3(1.0f, 2.0f, 3.0f));
477 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
478 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
480 double a = 0.707f * 0.707f + 0.189f * 0.189f + 0.378f * 0.378f + 0.567f * 0.567f;
482 var result = testingTarget.LengthSquared();
483 Assert.AreEqual(float.Parse(a.ToString("F2")), float.Parse(result.ToString("F2")), "LengthSquared function return incorrect value");
485 testingTarget.Dispose();
486 tlog.Debug(tag, $"RotationLengthSquared END (OK)");
491 [Description("Rotation Normalize.")]
492 [Property("SPEC", "Tizen.NUI.Rotation.Normalize M")]
493 [Property("SPEC_URL", "-")]
494 [Property("CRITERIA", "MR")]
495 [Property("AUTHOR", "guowei.wang@samsung.com")]
496 public void RotationNormalize()
498 tlog.Debug(tag, $"RotationNormalize START");
500 var testingTarget = new Rotation(new Radian(6.0f), new Vector3(1.0f, 2.0f, 3.0f));
501 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
502 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
504 testingTarget.Normalize();
506 Radian radian = new Radian(0.0f);
507 Vector3 axis = new Vector3();
508 testingTarget.GetAxisAngle(axis, radian);
510 Assert.AreEqual(0.27f, float.Parse(axis.X.ToString("F2")), "Vector3 got from Normalize is not correct, X value is not correct");
511 Assert.AreEqual(0.53f, float.Parse(axis.Y.ToString("F2")), "Vector3 got from Normalize is not correct, Y value is not correct");
512 Assert.AreEqual(0.80f, float.Parse(axis.Z.ToString("F2")), "Vector3 got from Normalize is not correct, Z value is not correct");
514 testingTarget.Dispose();
515 tlog.Debug(tag, $"RotationNormalize END (OK)");
520 [Description("Rotation Normalized.")]
521 [Property("SPEC", "Tizen.NUI.Rotation.Normalized M")]
522 [Property("SPEC_URL", "-")]
523 [Property("CRITERIA", "MR")]
524 [Property("AUTHOR", "guowei.wang@samsung.com")]
525 public void RotationNormalized()
527 tlog.Debug(tag, $"RotationNormalized START");
529 Rotation rotation = new Rotation(new Radian(6.0f), new Vector3(1.0f, 2.0f, 3.0f));
531 Radian radian = new Radian(0.0f);
532 Vector3 axis = new Vector3();
533 rotation.GetAxisAngle(axis, radian);
535 Assert.AreEqual(0.27f, float.Parse(axis.X.ToString("F2")), "X value is not correct");
536 Assert.AreEqual(0.53f, float.Parse(axis.Y.ToString("F2")), "Y value is not correct");
537 Assert.AreEqual(0.80f, float.Parse(axis.Z.ToString("F2")), "Z value is not correct");
539 var testingTarget = rotation * 5.0f;
540 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
541 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
543 var result = testingTarget.Normalized();
544 Radian radian2 = new Radian(0.0f);
545 Vector3 axis2 = new Vector3();
546 result.GetAxisAngle(axis2, radian2);
548 Assert.AreEqual(0.27f, float.Parse(axis2.X.ToString("F2")), "X value got from Normalized is not correct");
549 Assert.AreEqual(0.53f, float.Parse(axis2.Y.ToString("F2")), "Y value got from Normalized is not correct");
550 Assert.AreEqual(0.80f, float.Parse(axis2.Z.ToString("F2")), "Z value got from Normalized is not correct");
553 testingTarget.Dispose();
554 tlog.Debug(tag, $"RotationNormalized END (OK)");
559 [Description("Rotation Conjugate.")]
560 [Property("SPEC", "Tizen.NUI.Rotation.Conjugate M")]
561 [Property("SPEC_URL", "-")]
562 [Property("CRITERIA", "MR")]
563 [Property("AUTHOR", "guowei.wang@samsung.com")]
564 public void RotationConjugate()
566 tlog.Debug(tag, $"RotationConjugate START");
568 var testingTarget = new Rotation(new Radian(6.0f), new Vector3(1.0f, 2.0f, 3.0f));
569 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
570 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
572 Radian radian = new Radian(0.0f);
573 Vector3 axis = new Vector3();
574 testingTarget.GetAxisAngle(axis, radian);
576 Assert.AreEqual(0.27f, float.Parse(axis.X.ToString("F2")), "X value is not correct");
577 Assert.AreEqual(0.53f, float.Parse(axis.Y.ToString("F2")), "Y value is not correct");
578 Assert.AreEqual(0.80f, float.Parse(axis.Z.ToString("F2")), "Z value is not correct");
580 testingTarget.Conjugate();
582 Radian radian2 = new Radian(0.0f);
583 Vector3 axis2 = new Vector3();
584 testingTarget.GetAxisAngle(axis2, radian2);
586 Assert.AreEqual(-0.27f, float.Parse(axis2.X.ToString("F2")), "X value got from Conjugate is not correct");
587 Assert.AreEqual(-0.53f, float.Parse(axis2.Y.ToString("F2")), "Y value got from Conjugate is not correct");
588 Assert.AreEqual(-0.80f, float.Parse(axis2.Z.ToString("F2")), "Z value got from Conjugate is not correct");
590 testingTarget.Dispose();
591 tlog.Debug(tag, $"RotationConjugate END (OK)");
596 [Description("Rotation Invert.")]
597 [Property("SPEC", "Tizen.NUI.Rotation.Invert M")]
598 [Property("SPEC_URL", "-")]
599 [Property("CRITERIA", "MR")]
600 [Property("AUTHOR", "guowei.wang@samsung.com")]
601 public void RotationInvert()
603 tlog.Debug(tag, $"RotationInvert START");
605 var testingTarget = new Rotation(new Radian(0.0f), new Vector3(0.0f, 0.0f, 0.0f)); //radian: 2.355f z: -1.0f
606 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
607 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
609 Rotation testingTargetConjugate = testingTarget;
611 testingTargetConjugate.Conjugate();
612 testingTargetConjugate *= 1.0f / testingTarget.LengthSquared();
614 Radian radian = new Radian(0.0f);
615 Vector3 axis = new Vector3();
616 testingTargetConjugate.GetAxisAngle(axis, radian);
618 Rotation testingTargetInvert = testingTarget;
619 testingTargetInvert.Invert();
621 Radian radian2 = new Radian(0.0f);
622 Vector3 axis2 = new Vector3();
623 testingTargetInvert.GetAxisAngle(axis2, radian2);
625 Assert.AreEqual(float.Parse(axis2.X.ToString("F2")), float.Parse(axis.X.ToString("F2")), "Invert function does not work, X value is not correct");
626 Assert.AreEqual(float.Parse(axis2.Y.ToString("F2")), float.Parse(axis.Y.ToString("F2")), "Invert function does not work, Y value is not correct");
627 Assert.AreEqual(float.Parse(axis2.Z.ToString("F2")), float.Parse(axis.Z.ToString("F2")), "Invert function does not work, Z value is not correct");
629 testingTarget.Dispose();
630 tlog.Debug(tag, $"RotationInvert END (OK)");
635 [Description("Rotation Log.")]
636 [Property("SPEC", "Tizen.NUI.Rotation.Log M")]
637 [Property("SPEC_URL", "-")]
638 [Property("CRITERIA", "MR")]
639 [Property("AUTHOR", "guowei.wang@samsung.com")]
640 public void RotationLog()
642 tlog.Debug(tag, $"RotationLog START");
644 using (Rotation rotation = new Rotation(new Radian(2.29f), new Vector3(0.0f, 0.0f, 0.0f)))
646 Rotation normalize = rotation;
647 normalize.Normalize();
648 Radian radian = new Radian(0.0f);
649 Vector3 axis = new Vector3();
650 normalize.GetAxisAngle(axis, radian);
652 using (Rotation testingTarget = normalize.Log())
654 using (Rotation exp = testingTarget.Exp())
656 Radian radian2 = new Radian(0.0f);
657 Vector3 axis2 = new Vector3();
658 exp.GetAxisAngle(axis2, radian2);
660 Assert.AreEqual(float.Parse(axis.X.ToString("F2")), float.Parse(axis2.X.ToString("F2")), "Log function does not wrok, X value is not correct");
661 Assert.AreEqual(float.Parse(axis.Y.ToString("F2")), float.Parse(axis2.Y.ToString("F2")), "Log function does not wrok, Y value is not correct");
662 Assert.AreEqual(float.Parse(axis.Z.ToString("F2")), float.Parse(axis2.Z.ToString("F2")), "Log function does not wrok, Z value is not correct");
667 tlog.Debug(tag, $"RotationLog END (OK)");
672 [Description("Rotation Exp.")]
673 [Property("SPEC", "Tizen.NUI.Rotation.Exp M")]
674 [Property("SPEC_URL", "-")]
675 [Property("CRITERIA", "MR")]
676 [Property("AUTHOR", "guowei.wang@samsung.com")]
677 public void RotationExp()
679 tlog.Debug(tag, $"Rotation START");
681 using (Rotation rotation = new Rotation(new Radian(2.29f), new Vector3(0.0f, 0.0f, 0.0f)))
683 Rotation normalize = rotation;
684 normalize.Normalize();
685 Radian radian = new Radian(0.0f);
686 Vector3 axis = new Vector3();
687 normalize.GetAxisAngle(axis, radian);
689 using (Rotation log = normalize.Log())
691 using (Rotation testingTarget = log.Exp())
693 Radian radian2 = new Radian(0.0f);
694 Vector3 axis2 = new Vector3();
695 testingTarget.GetAxisAngle(axis2, radian2);
697 Assert.AreEqual(float.Parse(axis.X.ToString("F2")), float.Parse(axis2.X.ToString("F2")), "Log function does not wrok, X value is not correct");
698 Assert.AreEqual(float.Parse(axis.Y.ToString("F2")), float.Parse(axis2.Y.ToString("F2")), "Log function does not wrok, Y value is not correct");
699 Assert.AreEqual(float.Parse(axis.Z.ToString("F2")), float.Parse(axis2.Z.ToString("F2")), "Log function does not wrok, Z value is not correct");
704 tlog.Debug(tag, $"Rotation END (OK)");
709 [Description("Rotation Dot.")]
710 [Property("SPEC", "Tizen.NUI.Rotation.Dot M")]
711 [Property("SPEC_URL", "-")]
712 [Property("CRITERIA", "MR")]
713 [Property("AUTHOR", "guowei.wang@samsung.com")]
714 public void RotationDot()
716 tlog.Debug(tag, $"RotationDot START");
718 Rotation rotation1 = new Rotation(new Radian(1.339f), new Vector3(0.072f, 0.713f, 0.695f));
719 Rotation rotation2 = new Rotation(new Radian(1.599f), new Vector3(0.853f, 0.479f, -0.200f));
721 float val = 0.784f * 0.697f + MyDot(new Vector3(0.045f, 0.443f, 0.432f), new Vector3(0.612f, 0.344f, -0.144f));
723 var result = Rotation.Dot(rotation1, rotation2);
725 Assert.AreEqual(float.Parse(result.ToString("F2")), float.Parse(val.ToString("F2")), "Dot function does not wrok");
729 tlog.Debug(tag, $"RotationDot END (OK)");
734 [Description("Rotation Lerp.")]
735 [Property("SPEC", "Tizen.NUI.Rotation.Lerp M")]
736 [Property("SPEC_URL", "-")]
737 [Property("CRITERIA", "MR")]
738 [Property("AUTHOR", "guowei.wang@samsung.com")]
739 public void RotationLerp()
741 tlog.Debug(tag, $"RotationLerp START");
743 Rotation rotation1 = new Rotation(new Radian(new Degree(-80.0f)), new Vector3(0.0f, 0.0f, 1.0f));
744 Rotation rotation2 = new Rotation(new Radian(new Degree(80.0f)), new Vector3(0.0f, 0.0f, 1.0f));
746 Radian radian = new Radian(0.0f);
747 Vector3 axis = new Vector3();
748 rotation2.GetAxisAngle(axis, radian);
750 var testingTarget = Rotation.Lerp(rotation1, rotation2, 1.0f);
751 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
752 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
754 Radian radian2 = new Radian(0.0f);
755 Vector3 axis2 = new Vector3();
756 testingTarget.GetAxisAngle(axis2, radian2);
758 Assert.AreEqual(float.Parse(axis.X.ToString("F2")), float.Parse(axis2.X.ToString("F2")), "Lerp function does not wrok, X value is not correct");
759 Assert.AreEqual(float.Parse(axis.Y.ToString("F2")), float.Parse(axis2.Y.ToString("F2")), "Lerp function does not wrok, Y value is not correct");
760 Assert.AreEqual(float.Parse(axis.Z.ToString("F2")), float.Parse(axis2.Z.ToString("F2")), "Lerp function does not wrok, Z value is not correct");
764 testingTarget.Dispose();
765 tlog.Debug(tag, $"RotationLerp END (OK)");
770 [Description("Rotation Slerp.")]
771 [Property("SPEC", "Tizen.NUI.Rotation.Slerp M")]
772 [Property("SPEC_URL", "-")]
773 [Property("CRITERIA", "MR")]
774 [Property("AUTHOR", "guowei.wang@samsung.com")]
775 public void RotationSlerp()
777 tlog.Debug(tag, $"RotationSlerp START");
779 Rotation rotation1 = new Rotation(new Radian(new Degree(120.0f)), new Vector3(0.0f, 0.0f, 1.0f));
780 Rotation rotation2 = new Rotation(new Radian(new Degree(130.0f)), new Vector3(0.0f, 0.0f, 1.0f));
782 Radian radia = new Radian(0.0f);
783 Vector3 axis = new Vector3();
784 rotation2.GetAxisAngle(axis, radia);
786 var testingTarget = Rotation.Slerp(rotation1, rotation2, 1.0f);
787 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
788 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
790 Radian radia2 = new Radian(0.0f);
791 Vector3 axis2 = new Vector3();
792 testingTarget.GetAxisAngle(axis2, radia2);
794 Assert.AreEqual(float.Parse(axis.X.ToString("F2")), float.Parse(axis2.X.ToString("F2")), "Slerp function does not wrok, X value is not correct");
795 Assert.AreEqual(float.Parse(axis.Y.ToString("F2")), float.Parse(axis2.Y.ToString("F2")), "Slerp function does not wrok, Y value is not correct");
796 Assert.AreEqual(float.Parse(axis.Z.ToString("F2")), float.Parse(axis2.Z.ToString("F2")), "Slerp function does not wrok, Z value is not correct");
800 testingTarget.Dispose();
801 tlog.Debug(tag, $"RotationSlerp END (OK)");
806 [Description("Rotation SlerpNoInvert.")]
807 [Property("SPEC", "Tizen.NUI.Rotation.SlerpNoInvert M")]
808 [Property("SPEC_URL", "-")]
809 [Property("CRITERIA", "MR")]
810 [Property("AUTHOR", "guowei.wang@samsung.com")]
811 public void RotationSlerpNoInvert()
813 tlog.Debug(tag, $"RotationSlerpNoInvert START");
815 Rotation rotation1 = new Rotation(new Radian(new Degree(120.0f)), new Vector3(0.0f, 0.0f, 1.0f));
816 Radian radian1 = new Radian(0.0f);
817 Vector3 axis1 = new Vector3();
818 rotation1.GetAxisAngle(axis1, radian1);
820 Rotation rotation2 = new Rotation(new Radian(new Degree(130.0f)), new Vector3(0.0f, 0.0f, 1.0f));
821 Radian radian2 = new Radian(0.0f);
822 Vector3 axis2 = new Vector3();
823 rotation2.GetAxisAngle(axis2, radian2);
825 var testingTarget = Rotation.SlerpNoInvert(rotation1, rotation2, 0.0f);
826 Radian radian3 = new Radian(0.0f);
827 Vector3 axis3 = new Vector3();
828 testingTarget.GetAxisAngle(axis3, radian3);
829 Assert.AreEqual(axis1.X, axis3.X, "SlerpNoInvert function does not wrok, X value is not correct");
830 Assert.AreEqual(axis1.Y, axis3.Y, "SlerpNoInvert function does not wrok, Y value is not correct");
831 Assert.AreEqual(axis1.Z, axis3.Z, "SlerpNoInvert function does not wrok, Z value is not correct");
833 testingTarget = Rotation.SlerpNoInvert(rotation1, rotation2, 1.0f);
834 testingTarget.GetAxisAngle(axis3, radian3);
835 Assert.AreEqual(axis2.X, axis3.X, "SlerpNoInvert function does not wrok, X value is not correct");
836 Assert.AreEqual(axis2.Y, axis3.Y, "SlerpNoInvert function does not wrok, Y value is not correct");
837 Assert.AreEqual(axis2.Z, axis3.Z, "SlerpNoInvert function does not wrok, Z value is not correct");
841 testingTarget.Dispose();
842 tlog.Debug(tag, $"RotationSlerpNoInvert END (OK)");
847 [Description("Rotation Squad.")]
848 [Property("SPEC", "Tizen.NUI.Rotation.Squad M")]
849 [Property("SPEC_URL", "-")]
850 [Property("CRITERIA", "MR")]
851 [Property("AUTHOR", "guowei.wang@samsung.com")]
852 public void RotationSquad()
854 tlog.Debug(tag, $"RotationSquad START");
856 Rotation start = new Rotation(new Radian(new Degree(45.0f)), new Vector3(0.0f, 0.0f, 1.0f));
857 Rotation end = new Rotation(new Radian(new Degree(30.0f)), new Vector3(0.0f, 1.0f, 3.0f));
858 Rotation ctrl1 = new Rotation(new Radian(new Degree(40.0f)), new Vector3(0.0f, 1.0f, 2.0f));
859 Rotation ctrl2 = new Rotation(new Radian(new Degree(35.0f)), new Vector3(0.0f, 2.0f, 3.0f));
861 var testingTarget = Rotation.Squad(start, end, ctrl1, ctrl2, 0.0f);
862 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
863 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
865 Radian radian1 = new Radian(0.0f);
866 Vector3 axis1 = new Vector3();
867 start.GetAxisAngle(axis1, radian1);
869 Radian radian2 = new Radian(0.0f);
870 Vector3 axis2 = new Vector3();
871 end.GetAxisAngle(axis2, radian2);
873 Radian radian3 = new Radian(0.0f);
874 Vector3 axis3 = new Vector3();
875 testingTarget.GetAxisAngle(axis3, radian3);
877 Assert.AreEqual(axis3.X, axis1.X, "Squad function does not wrok, X value is not correct");
878 Assert.AreEqual(axis3.Y, axis1.Y, "Squad function does not wrok, Y value is not correct");
879 Assert.AreEqual(axis3.Z, axis1.Z, "Squad function does not wrok, Z value is not correct");
881 testingTarget = Rotation.Squad(start, end, ctrl1, ctrl2, 1.0f);
883 testingTarget.GetAxisAngle(axis3, radian3);
885 Assert.AreEqual(axis3.X, axis2.X, "Squad function does not wrok, X value is not correct");
886 Assert.AreEqual(axis3.Y, axis2.Y, "Squad function does not wrok, Y value is not correct");
887 Assert.AreEqual(axis3.Z, axis2.Z, "Squad function does not wrok, Z value is not correct");
889 testingTarget.Dispose();
890 tlog.Debug(tag, $"RotationSquad END (OK)");
895 [Description("Rotation AngleBetween.")]
896 [Property("SPEC", "Tizen.NUI.Rotation.AngleBetween M")]
897 [Property("SPEC_URL", "-")]
898 [Property("CRITERIA", "MR")]
899 [Property("AUTHOR", "guowei.wang@samsung.com")]
900 public void RotationAngleBetween()
902 tlog.Debug(tag, $"RotationAngleBetween START");
904 using (Radian radian1 = new Radian(new Degree(80.0f)))
906 Rotation rotation1 = new Rotation(radian1, Vector3.YAxis);
907 using (Radian radian2 = new Radian(new Degree(90.0f)))
909 Rotation rotation2 = new Rotation(radian2, Vector3.YAxis);
911 float value1 = Rotation.AngleBetween(rotation1, rotation2);
912 float value2 = (90.0f - 80.0f) * 3.14f / 180.0f;
913 Assert.AreEqual(float.Parse(value1.ToString("F2")), float.Parse(value2.ToString("F2")), "AngleBetween function does not work.");
921 tlog.Debug(tag, $"RotationAngleBetween END (OK)");
926 [Description("Rotation Dispose.")]
927 [Property("SPEC", "Tizen.NUI.Rotation.Dispose M")]
928 [Property("SPEC_URL", "-")]
929 [Property("CRITERIA", "MR MCST")]
930 [Property("AUTHOR", "guowei.wang@samsung.com")]
931 public void RotationDispose()
933 tlog.Debug(tag, $"RotationDispose START");
937 using (Radian radian = new Radian(new Degree(80.0f)))
939 var testingTarget = new Rotation(radian, Vector3.YAxis);
940 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
941 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
943 testingTarget.Dispose();
948 Assert.Fail("Caught Exception" + e.ToString());
951 tlog.Debug(tag, $"RotationDispose END (OK)");
956 [Description("Rotation Rotate.")]
957 [Property("SPEC", "Tizen.NUI.Rotate. M")]
958 [Property("SPEC_URL", "-")]
959 [Property("CRITERIA", "MR")]
960 [Property("AUTHOR", "guowei.wang@samsung.com")]
961 public void RotationRotate()
963 tlog.Debug(tag, $"RotationRotate START");
965 var testingTarget = new Rotation(new Radian(new Degree(180.0f)), new Vector3(1.0f, 0.0f, 0.0f));
966 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
967 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
969 using (Vector3 vec = new Vector3(0.0f, 1.0f, 0.0f))
971 var result = testingTarget.Rotate(vec);
972 Assert.IsNotNull(result, "Can't create success object Vector3");
973 Assert.IsInstanceOf<Vector3>(result, "Should return Vector3 instance.");
976 testingTarget.Dispose();
977 tlog.Debug(tag, $"RotationRotate END (OK)");
982 [Description("Rotation Rotate.")]
983 [Property("SPEC", "Tizen.NUI.Rotate. M")]
984 [Property("SPEC_URL", "-")]
985 [Property("CRITERIA", "MR")]
986 [Property("AUTHOR", "guowei.wang@samsung.com")]
987 public void RotationRotateWithVector4()
989 tlog.Debug(tag, $"RotationRotateWithVector4 START");
991 var testingTarget = new Rotation(new Radian(new Degree(180.0f)), new Vector3(0.0f, 1.0f, 0.0f));
992 Assert.IsNotNull(testingTarget, "Can't create success object Rotation");
993 Assert.IsInstanceOf<Rotation>(testingTarget, "Should return Rotation instance.");
995 using (Vector4 vec = new Vector4(1.0f, 0.0f, 0.0f, 0.0f))
997 var result = testingTarget.Rotate(vec);
998 Assert.IsNotNull(result, "Can't create success object Vector4");
999 Assert.IsInstanceOf<Vector4>(result, "Should return Vector4 instance.");
1002 testingTarget.Dispose();
1003 tlog.Debug(tag, $"RotationRotateWithVector4 END (OK)");