Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7410143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:11:15+00:00 2026-05-29T06:11:15+00:00

Here is the problem I’m trying to solve for my game. I have this

  • 0

Here is the problem I’m trying to solve for my game.

I have this scenario:
enter image description here

I’m trying to solve for the position and size of the green rectangle. The circle is at 50%, 40% of the screen and its radius is proportional to the height of the screen.

The green rectangle must always be 10 pixels away from the bottom. Its left corner must be 10 pixels away also. And as can be seen in the image, the distance from the top right corner until the rectangle touches the circle is 10 pixels also.

Another constraint is that the green rectangle must always be 3 times wider than its height (aspect ratio).

Given these constraints, how can I solve for the position and size of the green rectangle?

Essentially, the Game Window can have a bunch of different aspect ratios so the green rectangle must look good in any of these situations.

I’m not necessarily looking for code but just an idea on how this could be solved.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:11:15+00:00Added an answer on May 29, 2026 at 6:11 am

    The thing to do in these situations is to describe the constraints mathematically, and see if it simplifies. This is an essential skill for geometric processing.

    Let’s assume the bottom left corner of the image area is (0,0). That puts the bottom-left corner of the rectangle at (10,10); we’ll call the top-right corner (x1,y1). I’ll assume you’ve already calculated where the circle will be since that’s pretty straight-forward, we’ll call the center (x2,y2) and the radius r.

    The first constraint: the rectangle is 3 times wider than it is tall.

    x1-10 = 3 * (y1-10)  or  x1 = 3 * (y1-10) + 10  or  x1 = 3*y1 - 20
    

    The second constraint: x1,y1 lies 10 pixels away from the circle. If we describe another circle 10 pixels larger than the first, the point will lie on it.

    (x1-x2)^2 + (y1-y2)^2 = (r+10)^2
    

    Substituting for x1:

    (3*y1 - 20 - x2)^2 + (y1-y2)^2 = (r+10)^2
    

    This is great, because r, x2, and y2 are known; the only unknown left is y1. Let’s see if we can gather all the y1’s together.

    (3*y1 + (-20 - x2))^2 + (y1-y2)^2 = (r+10)^2
    3^2*y1^2 + 2*(3*y1*(-20-x2) + (-20-x2)^2 + y1^2 + 2*y1*-y2 + y2^2 = (r+10)^2
    3^2*y1^2 + y1^2 + 6*(-20-x2)*y1 + 2*-y2*y1 + y2^2 = (r+10)^2
    (3^2+1)*y1^2 + (-120 - 6*x2 - 2*y2)*y1 + y2^2 = (r+10)^2
    

    At this point it’s looking almost like a quadratic equation. One more little tweak:

    10 * y1^2 + (-120 - 6*x2 - 2*y2) * y1 + (y2^2 - (r+10)^2) = 0
    

    The final step is to apply the Quadratic Formula.

    a*y1^2 + b*y1 + c = 0
    a = 10
    b = (-120 - 6*x2 - 2*y2)
    c = (y2^2 - (r+10)^2)
    y1 = (-b +/- sqrt(b^2 - 4*a*c)) / 2*a
    

    There are two possible answers from the quadratic equation, but one of them will put the rectangle on the far side of the circle. It should be easy to eliminate that case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an interesting problem here I've been trying to solve for the last
I'm trying to solve the problem here but I don't know why my code
I have some problem here. Here it is: I have this class public class
Here is problem I'm trying to solve. It's for logistics company. I got all
Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello
I have a problem here. My Zend_Forms do not render in view script. Via
I'm having a strange problem here... I have an ASP.NET 3.5 application that has
I've got some problem with my function and don't know how to solve this
Now here's a fun problem. I have an object array as the following: objRequests
Well the problem here is that if you have one DataTemplate for a type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.