/// <summary> /// return true if the position is inside the sphape /// </summary> /// <param name="otherPosition">position to test</param> /// <returns>true if inside the shape</returns> public bool IsInsideShape(Vector3 otherPosition) { if (_circle.IsAbove(otherPosition)) { return(ExtVector3.Distance(otherPosition, Position) <= _realRadius); } return(false); }
public ExtCylinder(Vector3 p1, Vector3 p2, float radius = 0.25f) : this() { _position = ExtVector3.GetMeanOfXPoints(p1, p2); _rotation = ExtQuaternion.QuaternionFromLine(p1, p2, Vector3.up); _rotation = ExtRotation.RotateQuaternion(_rotation, new Vector3(90, 0, 0)); _localScale = new Vector3(1, 1, 1); _cylinderMatrix = Matrix4x4.TRS(_position, _rotation, _localScale * 1); //why radius a 0.25, and lenght * 0.8 ?? I don't know, //it's there to match the first constructor(position, rotation, scale) _radius = radius; _lenght = ExtVector3.Distance(p2, p1) * 0.8f; _lenghtSquared = _lenght * _lenght; _radiusSquared = _radius * _radius; _realRadius = _radius * MaxXY(_localScale); _realSquaredRadius = _realRadius * _realRadius; UpdateMatrix(); }
/// <summary> /// return true if the position is inside the sphape /// </summary> /// <param name="otherPosition">position to test</param> /// <returns>true if inside the shape</returns> public bool IsInsideShape(Vector3 otherPosition) { return(ExtVector3.Distance(otherPosition, Position) <= _realRadius); }