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

  • Home
  • SEARCH
  • 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 6814347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:40:42+00:00 2026-05-26T20:40:42+00:00

I made this application that lets the user draw a line on the screen

  • 0

I made this application that lets the user draw a line on the screen and the ball bounces off the line realistically with the angle it would bounce at in real life and stuff. But it only worked for a straight line. Now I’m trying to make it curved.

I have decided to feet clear from the calculus method as the matrices involved seem scarier than needed. What I am doing instead is in a -(void)touchesMoved event having it record the current point of the touch in a CGPoint array. Then to find the collision, I have a for loop like for (int i = 2; i <= numberOfPoints; i++) { That flies through all values for i as the numberOfPoints increases. So for collisions I assumed I would get the slope of the line between i and i-1, then get the perpendicular distance from the ball to that line and when it nears zero a collision has ocurred, just as I did in the straight line version.

This does not work however. Does anyone have any tips at all for a better way to do this? I have really stressed all of my options for this one

  • 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-26T20:40:43+00:00Added an answer on May 26, 2026 at 8:40 pm

    Using i and i-1 to calculate the slope simplifies it too much. I would suggest:

    1. Widening the distance between the two points to calculate the slope (i and i-4 for example). The reason is that to the human eye, the difference is imperceptible for two consecutive points. The eye will perceive the same slope for points slightly further apart. However, points which are further apart might provide you with a more accurate slope.

    2. If the point of collision is i, try averaging the slopes between (i,i-1), (i,i-2), (i,i-3), (i,i+1), (i,i+2), (i,i+3). I feel that this should also give you a better result.

    If I were you, I’d use option 2.

    You can also use a mixture of the two options by choosing sets of points that are further apart and then averaging those slopes.

    Also, as a side note, I’m assuming you know about this already, but have you heard of Box2D

    EDIT:

    One more thing… if you can figure out a way to alias the user’s curved line segment into multiple straight line segments, you can simply use your old algorithm.

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

Sidebar

Related Questions

I have this application I made on a utility based app. How would I
I've made an Area project for my ASP.NET MVC application called 'Admin'. This will
Somebody knows an example of this? an application made with JSF 2.0 and EJB
I made this little Cocoa app with a WebView that displays Google Maps in
I made this function to verify a user's twitter credentials. Its running on two
I am working on an iPhone application that runs in portrait mode only. This
I'm creating an air application that allows the user to create, edit and save
Made this nice little loop for hiding and showing div's, works as a charm
I made this code with jQuery to fade images ( but not the one
I made this bookmarklet: javascript:(function(){var s=document.createElement('script');s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');document.getElementsByTagName('body')[0].appendChild(s);$('#hldIntMain').hide();$('#fadeBackground').hide();return false;})() Formatted code: // Add in jQuery var

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.