/// <summary> /// Return the status of if point is inside the box /// </summary> public bool PointInBox(Vector3 point) { return (XInterval.ValueInInterval(point.x) // in x interval && // and YInterval.ValueInInterval(point.y) // in y interval && // and ZInterval.ValueInInterval(point.z)); // in z interval }
// Update is called once per frame void Update() { // Updates AnInteval with values entered by the user AnInterval.MinValue = IntervalMin; AnInterval.MaxValue = IntervalMax; AnInterval.IntervalColor = MyDrawObject.NoCollisionColor; // assume point is outside // computes inside/outside of the current TestPosition.y value Vector3 pos = TestPosition.transform.localPosition; bool isInside = (pos.y >= IntervalMin) && (pos.y <= IntervalMax); if (isInside) { Debug.Log("Position In Interval! (" + IntervalMin + ", " + IntervalMax + ")"); AnInterval.IntervalColor = MyDrawObject.CollisionColor; // The inside functionality is also supported by MyYInterval Debug.Assert(AnInterval.ValueInInterval(pos.y)); } }