Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by 123Hyrule · Feb 02, 2013 at 04:29 PM · verticesvectortrianglesintersect

Check if a vector is close to a mesh

Hello! I'd like to know what the fastest way to detect if a vector is relatively close to a mesh intersection. Using rays would be far too expensive for what I'm doing. I was trying to find a way to go through each vertex and check the vertices it's connected to (Which I did successfully) and then check if the vector is close to intersecting a triangle between them (Which I did not do successfully)

Any help is appreciated. Thanks!

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robertbu · Feb 02, 2013 at 05:06 PM 0
Share

Do you mean a vector or a point?

avatar image 123Hyrule · Feb 02, 2013 at 05:16 PM 0
Share

Trying to see how close a 3D point in world space is to touching a mesh.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by robertbu · Feb 03, 2013 at 04:38 PM

This is an interesting problem, so I poked around a bit. There is a variety of both math and code for finding the distance between a point and a triangle on the net. Here are two links to code (will have to be translated):

  • PointTriangleDistance

  • Distance Between Point and Triangle in 3D

I also found an interesting algorithm by DarrenW at the bottom of this page:

Determine if a 3D point is within a triangle

It was interesting for two reasons. First it may give you a way of determining nearness without actually calculating the distance. Second, it may give you the tools to determine which side of the triangle the points is on (I'm slow with this kind of math and would have to plod out an answer to the 'mays'...perhaps someone else on the list with a stronger math background can comment). I'm not sure why you are doing the calculations, but if you are calculating nearness to a closed object, determining if the point is inside the object may be important.

I also bumped into this page on the Unity Community Wiki:

3d Math functions

It doesn't directly solve your problem, but it does have solutions that there were building block to some of the algorithms on the net.

If you are going to do this a lot (same mesh different points), it will likely make sense to preprocess the mesh and build some data structures for faster searching. Good Luck.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image 123Hyrule · Feb 04, 2013 at 02:33 AM 0
Share

Wow, thanks!

I never get answers like this.

If it makes you guys happy, I'm attempting to make a real-time GI implementation for Unity, and perhaps even Unity Free, to be released publicly. I have no promises that I will be able to get it done, as I am decently slow myself, and may not know how to code some of the functions to be optimized for modern PC's. But, if I can, I will be sure to release it.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

mesh into smaller triangles 0 Answers

Accessing Mesh: Triangle and Vertex array fields directly? 0 Answers

Want to create a new mesh (single triangle) "cloned" from an already existing triangle .... 2 Answers

Making Different vertices,triangle,uv maps in the same mesh 1 Answer

65,000 vertices or 65,000 triangles? Disambiguation please. 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges