private Vector3 maxRot_m; // max rotation angles (degrees) #endregion #region Methods public PoseVoxel(Vector3 minPosition, Vector3 maxPosition, Vector3 minEulerAngleRotation, Vector3 maxEulerAngleRotation) { minPos_m = minPosition; maxPos_m = maxPosition; minRot_m = EulerClamper.ClampEulerVector(minEulerAngleRotation); maxRot_m = EulerClamper.ClampEulerVector(maxEulerAngleRotation); }
private bool hardRotContains(float min, float max, float value) { value = EulerClamper.ClampEuler(value); return ((value <= 360 && value >= min) || (value >= 0 && value <= max)); }
private bool rotContains(Pose pose) { Vector3 eulers = pose.Rotation.eulerAngles; eulers = new Vector3( EulerClamper.ClampEuler(eulers.x), EulerClamper.ClampEuler(eulers.y), EulerClamper.ClampEuler(eulers.z)); bool contained = true; // Prep repeated values float min = minRot_m.x; float max = maxRot_m.x; float value = eulers.x; for (int i = 0; i < 3; i++) { min = minRot_m[i]; max = maxRot_m[i]; value = eulers[i]; if (isEasyRotComparison(min, max)) { contained = contained && easyRotContains(min, max, value); } else { contained = contained && hardRotContains(min, max, value); } if (!contained) { break; } } return(contained); }
private Vector2 getMinMax(float value, MinMaxTypes minMaxType) { Vector2 minMax = new Vector2(0, 0); float min = 0; float max = 0; float width = 0; switch (minMaxType) { case MinMaxTypes.x: width = xWidth; break; case MinMaxTypes.y: width = yWidth; break; case MinMaxTypes.z: width = zWidth; break; case MinMaxTypes.xRot: width = xDegree; break; case MinMaxTypes.yRot: width = yDegree; break; case MinMaxTypes.zRot: width = zDegree; break; default: Debug.LogError("PoseVoxelSet: Encountered unknown min-max type! Please update the enum for this and the logic in this method."); break; } if (width == 0) { return(Vector2.zero); } min = (int)(value / width); max = min + 1; min *= width; max *= width; // Accommodate for rotation issues if (minMaxType == MinMaxTypes.xRot || minMaxType == MinMaxTypes.yRot || minMaxType == MinMaxTypes.zRot) { min = EulerClamper.ClampEuler(min); max = EulerClamper.ClampEuler(max); } minMax.x = min; minMax.y = max; return(minMax); }