This content has been marked as final. Show 3 replies
Applied CD wrote:
> I need a fast method for deriving the rect defined by two points.
> I?ve done this before using min/max comparisons for each side but I
> thought the following would be an incredibly simple one-liner to
> produce the same result, problem is it always returns rect(0,0,0,0).
> Is there a bug in the union method or am I overlooking something?
> pointA = some point
> pointB = some point
> myRect =
Union: "returns the smallest rectangle that encloses the two *rectangles*
rect1 and rect2."
Go with your min/max method: it will take next-to-no-time. Assuming that
what you need the rect for actually requires the rect to be "right-way-up".
Thanks Andrew, I did end up using a four line min/max solution, works fast enough.
You could still make it one line;
myRect = rect( [pointA, pointB].min(), [pointA, pointB].min(), [pointA, pointB].max(), [pointA, pointB].max() )