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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:40:20+00:00 2026-06-01T09:40:20+00:00

I need a fastest way to find any point inside triangle(not edges) in 2D.

  • 0

I need a fastest way to find any point inside triangle(not edges) in 2D. Any help?

  • 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-01T09:40:21+00:00Added an answer on June 1, 2026 at 9:40 am

    If your triangle is expressed as points, you’re going to have to take every coordinate into consideration, so Steve Jessop’s answer is nearly optimal.

    Note all you actually need to do is start at one point and bump it towards the two others a limited amount. That’s what averaging accomplishes, but in a very specific way.

    The addition is fast. The division may be slow depending on the platform and compiler.

    For example, on modern ARM cores I’d choose this version any day over averaging:

    xm = (x0 + (x1 + x2) / 2) / 2
    ym = (y0 + (y1 + y2) / 2) / 2
    

    If the variables are integer the compiler should optimize the divisions to bit shifts which, if scheduled correctly, are largely free in ARM. If the variables are floats or doubles the compiler should optimize them to simple exponent decrements. Floating point division is known to be relatively slow.

    Ultimately, test and see. Unless you’re doing relatively low level code optimization, you likely won’t see a difference. On the other hand, if you’re using this in a tight inner loop, you might.

    To provide some intuition as to why this works: First we find the midpoint of the line segment formed by (x1, y1) and (x2, y2). Then we find the midpoint between the line segment formed by that point and (x0, y0). If you draw a diagram of a triangle and do this, it becomes immediately clear that this works.

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

Sidebar

Related Questions

I need fastest way to find the values in array A that their mods
What is the fastest way to execute many PHP pages. I will not need
I need fastest way to convert files from latin1 to utf-8 in python. The
I would like to find the fastest way to check if a file exists
What would be the fastest and/or easiest (speed preferred) way to find an object,
I need the fastest way to see if an ip address is reachable. On
which is the fastest way to find the union and intersection between two lists?
I'm looking for the fastest way to find all strings in a collection starting
I am trying to find the fastest and most efficient way to calculate slopes
I'm trying to find the fastest way to get the complete preprocessed source code

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.