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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:27:52+00:00 2026-05-23T07:27:52+00:00

This is probably a very stupid math question, but i can’t seem to figure

  • 0

This is probably a very stupid math question, but i can’t seem to figure it out. What i have is a circle at point A that i can click on and drag the mouse oway from it. When the mouse is released – the release point B is considered a target point and the ball has to move in that direction. What i’m doing now is something like this:

velocityX = (b.x - a.x) / somenumber
velocityY = (b.y - a.y) / somenumber

This allows me to use different “shot” speeds the further away the mouse is released from the circle. But now i realised that i don’t like this idea and instead i want to do it the following way:

  • to have a minimum and maximum speed (pixels per animation frame)
  • to select the speed from this interval prior to the shot
  • to use the point B simply for easier targeting. The shot speed is preselected and it should’t depend on how far the mouse is released

I know it should be dead simple, but how do i (knowing point A and B coordinates, min, max and selected velocity) set x and y velocities to the circle taking into account the direction of the shot?

  • 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-23T07:27:53+00:00Added an answer on May 23, 2026 at 7:27 am

    Just normalize the vector from the center of the circle to the point and then multiply by the speed you want. In any goodl vector library there is such a function, but just to clarify:

    length=square_root((b.x - a.x)^2+(b.y - a.y)^2)
    velocityX = (b.x - a.x) / length * speed
    velocityY = (b.y - a.y) / length * speed
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a very simple and stupid question to ask, but I have
This is probably a very stupid question. But assume that I have a DLL
This is probably a very stupid question, but I am just not sure which
This is probably a very stupid question for SQL stalwarts, but I just want
this is probably a very stupid question; in a bash script, given the output
I know this is probably a very simple question but how would I do
This probably sounds really stupid but I have noo idea how to implement jquery's
This is probably a stupid question but my googling isn't finding a satisfactory answer.
This may sound like a very stupid question - and probably is! For an
This is probably a stupid question but I need to ask it because I've

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.