Compare commits
5 Commits
67cf8b31fb
...
83159b487d
Author | SHA1 | Date | |
---|---|---|---|
83159b487d | |||
4ef3b24eae | |||
3eaa1ba31b | |||
19b4c33e05 | |||
![]() |
2ebf4b4040 |
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
using Vector3Float = UnityEngine.Vector3;
|
||||
//using Vector3Float = UnityEngine.Vector3;
|
||||
using Vector3 = UnityEngine.Vector3;
|
||||
#endif
|
||||
|
||||
namespace LinearAlgebra {
|
||||
@ -66,16 +67,16 @@ namespace LinearAlgebra {
|
||||
public readonly static Spherical forward = new(1, Direction.forward);
|
||||
|
||||
|
||||
public static Spherical FromVector3Float(Vector3Float v) {
|
||||
float distance = v.magnitude;
|
||||
if (distance == 0.0f)
|
||||
return Spherical.zero;
|
||||
else {
|
||||
float verticalAngle = (float)((Angle.pi / 2 - Math.Acos(v.y / distance)) * Angle.Rad2Deg);
|
||||
float horizontalAngle = (float)Math.Atan2(v.x, v.z) * Angle.Rad2Deg;
|
||||
return Spherical.Degrees(distance, horizontalAngle, verticalAngle);
|
||||
}
|
||||
}
|
||||
// public static Spherical FromVector3Float(Vector3Float v) {
|
||||
// float distance = v.magnitude;
|
||||
// if (distance == 0.0f)
|
||||
// return Spherical.zero;
|
||||
// else {
|
||||
// float verticalAngle = (float)((Angle.pi / 2 - Math.Acos(v.y / distance)) * Angle.Rad2Deg);
|
||||
// float horizontalAngle = (float)Math.Atan2(v.x, v.z) * Angle.Rad2Deg;
|
||||
// return Spherical.Degrees(distance, horizontalAngle, verticalAngle);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static Spherical FromVector3(Vector3 v) {
|
||||
float distance = v.magnitude;
|
||||
@ -88,21 +89,21 @@ namespace LinearAlgebra {
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3Float ToVector3Float() {
|
||||
float verticalRad = (Angle.pi / 2) - this.direction.vertical * Angle.Deg2Rad;
|
||||
float horizontalRad = this.direction.horizontal * Angle.Deg2Rad;
|
||||
float cosVertical = (float)Math.Cos(verticalRad);
|
||||
float sinVertical = (float)Math.Sin(verticalRad);
|
||||
float cosHorizontal = (float)Math.Cos(horizontalRad);
|
||||
float sinHorizontal = (float)Math.Sin(horizontalRad);
|
||||
// public Vector3Float ToVector3Float() {
|
||||
// float verticalRad = (Angle.pi / 2) - this.direction.vertical * Angle.Deg2Rad;
|
||||
// float horizontalRad = this.direction.horizontal * Angle.Deg2Rad;
|
||||
// float cosVertical = (float)Math.Cos(verticalRad);
|
||||
// float sinVertical = (float)Math.Sin(verticalRad);
|
||||
// float cosHorizontal = (float)Math.Cos(horizontalRad);
|
||||
// float sinHorizontal = (float)Math.Sin(horizontalRad);
|
||||
|
||||
float x = this.distance * sinVertical * sinHorizontal;
|
||||
float y = this.distance * cosVertical;
|
||||
float z = this.distance * sinVertical * cosHorizontal;
|
||||
// float x = this.distance * sinVertical * sinHorizontal;
|
||||
// float y = this.distance * cosVertical;
|
||||
// float z = this.distance * sinVertical * cosHorizontal;
|
||||
|
||||
Vector3Float v = new(x, y, z);
|
||||
return v;
|
||||
}
|
||||
// Vector3Float v = new(x, y, z);
|
||||
// return v;
|
||||
// }
|
||||
|
||||
public Vector3 ToVector3() {
|
||||
float verticalRad = (Angle.pi / 2) - this.direction.vertical * Angle.Deg2Rad;
|
||||
|
@ -1,3 +1,4 @@
|
||||
#if !UNITY_5_6_OR_NEWER
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace LinearAlgebra.Test {
|
||||
@ -26,3 +27,4 @@ namespace LinearAlgebra.Test {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -24,7 +24,7 @@ namespace RoboidControl {
|
||||
//thisParticipant = participant;
|
||||
}
|
||||
|
||||
public TouchSensor(Thing parent) : base(parent) { }
|
||||
public TouchSensor(Thing parent, bool invokeEvent = true) : base(parent, (byte)Type.TouchSensor, invokeEvent) { }
|
||||
|
||||
public ParticipantUDP thisParticipant;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user