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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:59:44+00:00 2026-06-06T04:59:44+00:00

The code I’m using in my collision detection code is this: (note: Vector3f is

  • 0

The code I’m using in my collision detection code is this:

(note: Vector3f is part of the LWJGL library.)

(Note2:Tri is a class composed of three of LWJGL’s Vector3fs. v1, v2, and v3.)

public Vector<Tri> getTrisTouching(Vector3f pos, float radius){
        Vector<Tri> tempVec = new Vector<Tri>();
        for(int i = 0; i < tris.size(); i++){
            Tri t = tris.get(i);

            Vector3f one_to_point = new Vector3f(0,0,0);
            Vector3f.sub(pos,t.v1,one_to_point);            //Storing vector A->P

            Vector3f one_to_two = new Vector3f(0,0,0);
            Vector3f.sub(t.v2,t.v1, one_to_two);            //Storing vector A->B

            Vector3f one_to_three = new Vector3f(0,0,0);
            Vector3f.sub(t.v3, t.v1, one_to_three);            //Storing vector A->C

            float q1 =  Vector3f.dot(one_to_point,  one_to_two) / one_to_two.lengthSquared();            // The normalized "distance" from a to
            float q2 =  Vector3f.dot(one_to_point,  one_to_three) / one_to_three.lengthSquared();            // The normalized "distance" from a to



            if (q1 > 0 && q2 > 0 && q1 + q2 < 1){
                tempVec.add(t);
            }
        }   

        return tempVec;
    }

My question is how do I correctly see if a point in space is touching one of my triangles?

  • 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-06T04:59:46+00:00Added an answer on June 6, 2026 at 4:59 am

    To test if your point is inside the triangle, create a ray with its origin at the test point and extend it to infinity. A nice easy one would be a ray which is horizontal ( e.g. y constant, and x increases to infinity. Then count the number of times it intersects with one of your polygon edges. Zero or an even number of intersections means you are outside the triangle. The nice thing about this it works not just for triangles but any polygon.

    http://erich.realtimerendering.com/ptinpoly/

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

Sidebar

Related Questions

code: #include<iostream> using namespace std; template<class T, int N> class point { T coordinate[N];
Code: var result = db.rows.Take(30).ToList().Select(a => AMethod(a)); db.rows.Take(30) is Linq-To-SQL I am using ToList()
Code below sets default values for new row if row is added using form.
Code: public class SMH extends Activity { public void onCreate(Bundle b) { super.onCreate(b); setContentView(R.layout.main);
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Code goes first: void foo(int x) { void bar(int); //is this forward-decl legal? bar(x);
Code Currently my code looks like that. $stmt = $this->db->prepare(SELECT m.id, m.from_id, m.to_id, m.subject,
I have this code to decode numeric html entities to the UTF8 equivalent character.
Code (Note that the result will not display properly without the images referenced) I'm
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.