VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
override void AVR.Core.AVR_SolidRay.UpdateRay ( )
inlineprotectedvirtual

Updates the ray. Called from Monobehaviour.Update()

An brief explanation on the math done here: Say alpha is the angle between RayForward and the y-axis. We want a minium alpha of 30°. Basic trigonometry tells us, that alpha >= 30° is equivalent with RayForward.y <= cos(30°). Consequently, RayForward.y will be clamped to exaclty cos(30°). What remains is setting the xz vector accordingly. Since the whole vector is normalized, the hypotenuse is 1. So pythagoras => 1^2 = |RayForward.xz|^2 + Rayforward.y^2 As a result, the length of RayForward.xz is equal to |RayForward.xz| = sqrt(1-RayForward.y^2) And since RayForward.y = cos(30°): |RayForward.xz| = sqrt(1-cos(30°)^2) = sin(30°) And this is what we do here. If the condition is violated, we set y=0, then multiply the normalized vector with sin(alpha) and finally set y to cos(alpha).

Reimplemented from AVR.Core.AVR_Ray.

Reimplemented in AVR.Motion.AVR_MovementRay.

Definition at line 40 of file AVR_SolidRay.cs.

41  {
42  _objectHit = false;
43  base.UpdateRay();
44  }