0
\$\begingroup\$

So I am instantiating 2 ovals/ellipses at runtime with random rotations. The first oval will always be spawned at the center. However, the second oval must be placed in a way that should always intersect/overlap the first oval, something like a Venn Diagram. How would I do so? We are talking 2D and the ovals are sprites

\$\endgroup\$
  • \$\begingroup\$ Can the ovals differ in size or shape or do they only differ in rotation? \$\endgroup\$ – Philipp Jul 23 at 12:05
  • \$\begingroup\$ Are there any constraints on the size / aspect ratio / relative orientations of the ovals, or the amount of overlap? Any bit of specificity can help us make simpler answers with more reliably desirable results. \$\endgroup\$ – DMGregory Jul 23 at 12:09
1
\$\begingroup\$

If you know the length of the distance from the middle of the sprite to the closest point on the outside of the oval (which can either be guessed and then adjusted or produced mathematically), then a reasonable approximation for the second ovals location would be new Vector2(oval1minDist + oval2minDist - offset, 0), where offset is a small but not negligible value. This ensures your ovals will always overlap by at least offset pixels. However, this solution doesn't account for the case where the ovals are long and skinny, in which case the ovals may form a cross.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.