ICE test vector inside cone

262 views
Skip to first unread message

Miquel Campos

unread,
Feb 18, 2013, 10:45:55 AM2/18/13
to soft...@listproc.autodesk.com
Hello,

I struggling to found a method for test if a vector is inside a cone defined by two other vectors. For example for know if a point of a bended arm, is the internal part  or the external of the elbow.

Alan send me this link the other day, but I did not success getting anything working in ICE:  http://stackoverflow.com/questions/10768142/verify-if-point-is-inside-a-cone-in-3d-space

Someone have any idea?


Thank you for the help!!. :D

Miq
----------------------------------------------------

Miquel Campos
www.akaosaru.com

Alok

unread,
Feb 18, 2013, 10:54:53 AM2/18/13
to soft...@listproc.autodesk.com
Do you have a ICE Scene setup ? You are wanting to test a point (represented as a pos vector) in a cone whose two inclined lines are defined by a vector, right ?

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.2238 / Virus Database: 2639/5610 - Release Date: 02/17/13


Alan Fregtman

unread,
Feb 18, 2013, 11:02:06 AM2/18/13
to XSI Mailing List
Yes.

For a bone, we'd be considering a cone drawing it out the direction of the X axis of the bone's transform, knowing only its angle. Is the given global pos inside it? And if so, how far is it from the imaginary center line of said cone?

Alok_Signature_email_.gif

Miquel Campos

unread,
Feb 18, 2013, 11:08:20 AM2/18/13
to soft...@listproc.autodesk.com
Thanks Alok :)

Here is the basic setup that I am using for the test.

Is just 3 vectors, two for represent the angle and one for represent the point. 

My idea was to normalize the vector so I can work  based only in the angles, but right now I not sure if it is the right approach.

----------------------------------------------------

Miquel Campos
www.akaosaru.com



2013/2/18 Alok <alok....@modusfx.com>
Alok_Signature_email_.gif
test inside Cone.rar

Alok

unread,
Feb 18, 2013, 11:28:01 AM2/18/13
to soft...@listproc.autodesk.com
I did not get time go through Miquel's scene but here is way :-

Refer to this diagram:



Part I (Finding whether the point is inside cone)

This would be a better solution (found on web but the math seems right):

S1 - Vector for one side of the cone  = Vector p1 - vector p2
S2 - Vector for the second side of the cone = Vector p1 - vector p4
p3 - Point Vector to test

Take the vector S2-S1 and the vector p3-S1. Normalize them both to unit length. Take their dot product. If this number is greater than or equal to the **cosine of the half-angle at the apex of the cone, then the point is inside the cone. (If it's exactly equal, then P3 is on the cone.)

** cosine of the half angle at the apex of cone: Can be easily found in ICE by angle between vectors node for the vector (S1 & S2). Divide by 2 and then take a cos  of that.


Part II (Finding the distance of the point from the central line of the cone)
This one comes from me :)

B = vector p4 - vector p2
p5 = 1 /2 of B

L = p1 - p5

Find the distance between point p3 and vector B through ICE.

Cheers !


Alok

unread,
Feb 18, 2013, 11:31:59 AM2/18/13
to soft...@listproc.autodesk.com
Sorry , correction in the last line :

Find the distance between point p3 and vector **L through ICE.


Miquel Campos

unread,
Feb 18, 2013, 11:36:53 AM2/18/13
to soft...@listproc.autodesk.com
Woah!  thanks for the super answer!  :D

----------------------------------------------------

Miquel Campos
www.akaosaru.com



2013/2/18 Alok <alok....@modusfx.com>
Sorry , correction in the last line :
Alok_Signature_email_.gif

Miquel Campos

unread,
Feb 18, 2013, 12:23:13 PM2/18/13
to soft...@listproc.autodesk.com
First patr doesn't give the value that I was expecting.  Not sure If I mistake something. 

Now I gone a try with part II


BTW: Part == approach ?? :P 

----------------------------------------------------

Miquel Campos
www.akaosaru.com



2013/2/18 Miquel Campos <miquel...@gmail.com>
Alok_Signature_email_.gif
test inside Cone 003.rar

Alok Gandhi

unread,
Feb 18, 2013, 12:37:53 PM2/18/13
to soft...@listproc.autodesk.com
Nope parts are two different solutions part 1 for testing point inside cone and part 2 for getting distance between point and axis of the cone. I am going to set a small scene and check myself it this works (in theory it should).

Will keep you posted.
--
Alok_Signature_email_.gif

Miquel Campos

unread,
Feb 18, 2013, 12:41:49 PM2/18/13
to soft...@listproc.autodesk.com
Thank you again :) I am continuing testing in my side. I will keep  you posted too. :)

----------------------------------------------------

Miquel Campos
www.akaosaru.com



2013/2/18 Alok Gandhi <alok.ga...@gmail.com>
Alok_Signature_email_.gif

Miquel Campos

unread,
Feb 18, 2013, 1:18:05 PM2/18/13
to soft...@listproc.autodesk.com
I believe,  I have it!!  testing the distance between the axis and the vector :D



----------------------------------------------------

Miquel Campos
www.akaosaru.com



2013/2/18 Miquel Campos <miquel...@gmail.com>
Alok_Signature_email_.gif
test inside Cone 004.rar

Alok Gandhi

unread,
Feb 18, 2013, 1:35:24 PM2/18/13
to soft...@listproc.autodesk.com
Good, and for part I my apologies, there is a slight change in what I posted, but it works, please find the attached scene and here is the screen cap

Inline image 1
--
Alok_Signature_email_.gif
image.jpeg
test_inside cone.7z

Miquel Campos

unread,
Feb 18, 2013, 1:39:32 PM2/18/13
to soft...@listproc.autodesk.com
Cool, thanks !   Plenty of solutions now . heheheheh
Alok_Signature_email_.gif
image.jpeg

Alok

unread,
Feb 18, 2013, 1:47:47 PM2/18/13
to soft...@listproc.autodesk.com
Just to make clear, the two parts are not the same solutions, testing the distance between the axis and the vector will not tell you whether the point is inside the cone or not.

Version: 2012.0.2238 / Virus Database: 2639/5613 - Release Date: 02/18/13


Miquel Campos

unread,
Feb 18, 2013, 1:56:41 PM2/18/13
to soft...@listproc.autodesk.com
The solution that I found testing the distance looks like is working nice. But I think is slightly different from what you posted in the first mail.


I will make more  deep test to be sure :)
----------------------------------------------------

Miquel Campos
www.akaosaru.com



2013/2/18 Alok <alok....@modusfx.com>
Alok_Signature_email_.gif

Alok

unread,
Feb 18, 2013, 2:09:40 PM2/18/13
to soft...@listproc.autodesk.com
Here is the pseudo code for everybody's benefit:





Miquel Campos

unread,
Feb 18, 2013, 2:40:33 PM2/18/13
to soft...@listproc.autodesk.com
Yep, you was right. Testing distance is not always right. Look like it works only in 2D plane :P

----------------------------------------------------

Miquel Campos
www.akaosaru.com



2013/2/18 Alok <alok....@modusfx.com>
Alok_Signature_email_.gif
jfdcihfh.jpg

Alok

unread,
Feb 18, 2013, 2:45:08 PM2/18/13
to soft...@listproc.autodesk.com
Well in that case you can use the scene setup that I sent you. It works perfectly in all scenarios with global coordinates. You can have the cone at whatever pos and rot and same for the test point.

Miquel Campos

unread,
Feb 18, 2013, 3:32:12 PM2/18/13
to soft...@listproc.autodesk.com
Finally here is my latest version. I used linear interpolate to found the axis base. Also, I used the global centre as a apex for simplicity

Thanks again for you help Alok .


:)  Miq

----------------------------------------------------

Miquel Campos
www.akaosaru.com



2013/2/18 Alok <alok....@modusfx.com>
Alok_Signature_email_.gif
test inside Cone 005.rar

Miquel Campos

unread,
Feb 18, 2013, 3:34:28 PM2/18/13
to soft...@listproc.autodesk.com
wop!  one of the ref is local pos :P must be global .
Alok_Signature_email_.gif

Alok

unread,
Feb 18, 2013, 3:37:29 PM2/18/13
to soft...@listproc.autodesk.com
:) glad to help

Alok Gandhi
Lead TD
Modusfx

Raffaele Fragapane

unread,
Feb 18, 2013, 10:23:08 PM2/18/13
to soft...@listproc.autodesk.com
Sounds like this has gone some circuitous way... :)
If you have two vectors describing the cone their average is the the cone's centripetal axis.

Take the two vectors, linearly interpolate them to 0.5. Lets call that C
Take your vector, measure its angle from the the one you got before (C)
Measure the Angle between your two cone vectors, call it a

Measure the angle between the vector you want to flag and C, if it's less than a/2 the vector is inside, if equal the vector is part of the cone's hull, if greater the vector is outside.

If you want the cone to have a base you can also throw in some basic trig, but since this seems to be a vector outside range scenario, I imagine you will want the cone to be of infinite height.

If you want it to be an "in potential reach" test, then it's not a cone anymore, as the base isn't flat but rather a section of a sphere, in which case before the above test also test that the length of your vector is shorter than the length of the bone, or it will always be out of reach.

Raffaele Fragapane

unread,
Feb 18, 2013, 10:46:29 PM2/18/13
to soft...@listproc.autodesk.com
Inline image 1
--
Our users will know fear and cower before our software! Ship it! Ship it and let them flee like the dogs they are!
Screenshot.png

Miquel Campos

unread,
Feb 18, 2013, 11:17:20 PM2/18/13
to soft...@listproc.autodesk.com
Thank Raffaele, 

I already have a solution that works for me. The scene is somewhere in the threat.  Anyway, I will test yours tomorrow (Sleep time in Montreal :P )   Thanks again! :D

BTW: how is going the new course preparations?   We need ( Math + ICE) Love :)

Cheers,
Miquel

----------------------------------------------------

Miquel Campos
www.akaosaru.com



2013/2/18 Raffaele Fragapane <raffsx...@googlemail.com>
Screenshot.png
Reply all
Reply to author
Forward
0 new messages