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 8309763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:13:14+00:00 2026-06-08T19:13:14+00:00

I have given a diagram of my current small problem that I need help

  • 0

Diagram of the meaning of this question.

I have given a diagram of my current small problem that I need help with. My main purpose is to keep the point from going outside the circle. Nothing else.

The center of the circle is positioned at (x, y).

I only solved a little bit of the problem, and that is the collision detection part of my problem, as given below:

public void bound(Point p, Circle c){
    double distance = Math.hypot(p.x - c.x, p.y - c.y);
    if (distance >= c.radius){
        //Clueless from here on out.
    }
}

The part where I left a comment is the spot I couldn’t figure anything out. I did tried to set the point’s velocityX and velocityY to 0, but I realized the point will just stay put whenever it touches the circle.

So, I’m sort of stuck.

  • 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-06-08T19:13:16+00:00Added an answer on June 8, 2026 at 7:13 pm

    I have resolved this issue.

    public void reflect(Hole h){
        //R = -2*(V dot N)*N + V
        //N is normalized.
        double nx = (this.position[0]+this.diameter/2) - (h.x+16);
        double ny = (this.position[1]+this.diameter/2) - (h.y+16);
        double nd = Math.hypot(nx, ny);
        if (nd == 0)
            nd = 1;
        nx /= nd;
        ny /= nd;
        double dotProduct = this.speed[0]*nx+this.speed[1]*ny;
        this.speed[0] += (float)(-2*dotProduct*nx);
        this.speed[1] += (float)(-2*dotProduct*ny);
    }
    
    public void reflectResponse() {
        for (int i = 0; i <= 1; i++) {
            position[i] -= speed[i];
            speed[i] *= 0.992f;
        }
    }
    

    I tried Oli Charlesworth’s method from the comments, but it made things more… “complicated” than I expected. Someone else mentioned I used a completely 100%, vector-based algorithm, since I’m relying a lot on vector-based movements.

    TIPS TO THOSE WHO DO READ THIS:

    1. If you’re working on object movements and collisions with vectors, seek vector-based algorithms.
    2. If you’re working with angles (either degrees or radians), use Oli Charlesworth’s method.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I have to plot a simple 3D graph/diagram with x,y,z coordinates given for
The following diagram illustrates a problem I have encountered creating a Manhattan diagram: Overlapping
Given the following diagram: Right now I have queries to find out how much
I suspect that the syntax diagram for a plsql_block as given in the Oracle®
I have a scenario as given in the below workflow diagram using core service.
I created a control, derived from Canvas , that should plot a live diagram,
I have given a default value 2.5 for a textbox called diff_Box and then
I have given 100% width to input box to fix to the browser width
i have given required permission : <uses-permission android:name=android.permission.WRITE_EXTERNAL_STORAGE /> hard-coded the path as /sdcard/filename
I have given bg image for radio button. It is working in chrome but

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.