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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:50:48+00:00 2026-05-12T06:50:48+00:00

Otherwise known as a hard edge, this is a line over which the mouse

  • 0

Otherwise known as a hard edge, this is a line over which the mouse cannot cross. Useful in games and the like.

Currently, I have a function that returns if my mouse cursor is in a polygon drawn on the screen. If it is not, I move my cursor to the last stored point that was in the polygon.

    if (!PointInPolygon(local, polyGon))
    {
        Cursor.Position = safePoint;
    }
    else
    {
        safePoint = Cursor.Position;
    }

I don’t like this for a couple reasons:

  • Due to slow update times or for whatever reason, I am sometimes able to break out of the box. This then stores that position as the safePoint, outside of the polygon. My mouse is then stuck in this position.

  • Sloped edges should pust the mouse in the slope direction. Pushing the mouse right againts an “/” shaped wall should end up with the cursor in the top right corner. But due to the nature of this approach, going over the line will reset the cursor to where it previously was. Continuing to push right will only keep reseting the cursor, and will not push it “up the slope.”

Are there any other approaches to tackle this problem? I’m mainly worried about the last issue: this slope transversal behavior is the main objective of my program and I need to get it working. Even if I use this basic method, any ideas for an optimization of that specific behavior?


EDIT:

It has been suggested by Reed that I instead return to the point that is CLOSEST to the current out-of-bounds point. Given the 4 corner points of a quadrilateral, how would I find the closest point in/on the shape?

  • 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-12T06:50:48+00:00Added an answer on May 12, 2026 at 6:50 am
    1. Find the equation of the edge line using the two endpoints.
    2. -(1/slope) gives the slope of the perpendicular line.
    3. Solve for line equation of perpendicular line using the known point across the edge (location of the true mouse)
    4. Solve for intersection of edge line and perpendicular line.
    5. Put the fake cursor at that location.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which useful (for performance or otherwise) constructions are valid bytecode, but not expressable in
I'm trying to detect Use after free() bugs, otherwise known as Dangling pointers. I
Is there anything more compact (or otherwise better) than this? <x:Array x:Key=titles Type=System:String> <System:String>Mr.</System:String>
I am using System.Reflection to load a type that I cannot otherwise load during
All of my tests for my Groovy code look like this public void testButtons()
I've just come across some code in Three20 that looks like this: SEL sel
This one just stabbed me hard. I don't know if it's the case with
I find it hard to believe I'm the first person to run into this
We have a cloud setup like this: User Request -> Perlbal (SSL unwrapping) ->
I'm storing the current date (otherwise known as the date of the ban) in

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.