Geometrical calculations : points, lines, planes : intersections, distances, angles

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

REPLY TO THREAD
 
Thread Tools Search this Thread Display Modes
Old 04 April 2008   #46
3 Planes Intersection

Here is a function for calculating the intersection of 3 planes.

At present, that is just a Plane-Plane intersection followed by a line-Plane Intersection but I think It should exist a shorter way to calculate that.

fn PPPIntersection pA nA pB nB pC nC =
(
    vD= cross nA nB
    perp= cross nA vD
    pD= pA + (dot (pB-pA) nB) * perp / (dot perp nB)
    pD + (dot (pC-pD) nC)*vD / (dot vD nC)
)


@Anubis: I am curious to know if this code returns always the expected result (except of course if the planes are parallel.)
 
Old 09 September 2008   #47
Circumcenter of a triangle

i know that Kameleon already posted a function for the finding the circumcenter of a triangle on the previous page, but to be honest I have no idea how it works, so I have written a different solution using barycentric coordinates:
fn circumcenter p1 p2 p3 = 
(
BC = distance p2 p3
CA = distance p3 p1
AB = distance p1 p2

baryCoords = [ (BC^2*(CA^2+AB^2-BC^2)), (CA^2*(AB^2+BC^2-CA^2)), (AB^2*(BC^2+CA^2-AB^2)) ]
triArea = baryCoords.x + baryCoords.y + baryCoords.z
baryCoords /= triArea -- normalize the barycentric coordinates
-- substitute in for P = uA + vB + wC
baryCoords.x * p1 + baryCoords.y * p2 + baryCoords.z * p3
)
References:
Circumcenter @ Wikipedia for the barycentric circumcenter forumla
6th post on this page for the formula to convert from barycentric to cartesian coordinates (P=uA+vB+wC)
 
Old 02 February 2009   #48
Essential library

Hi guys,
I put together an essential library of geometrical calculations functions. They're approximately those already shown here a little polished, so this thread was back credited too. You can find them here.

- Enrico
__________________
IllusionCatalyst Instrument set for 3ds Max │ AliquaForma Personal portfolio in fieri
 
Old 06 June 2009   #49
thank you everyone!

thank you everyone! great collection, found it super useful!

also thank you Syncviews for providing us with such informative site : )
will be referring to your site frequently!
 
Old 09 September 2010   #50
What about getting an intersection between 2 curves? Is it a matter of checking each step in the segment (as lines)?

Additionally, is there a way to do a fast check on a "spaghetti" of splines to narrow down possible intersections? I looked into some variation of delaunay (at least the radial part) but it's not really suited.
 
Old 09 September 2010   #51
Originally Posted by duke: What about getting an intersection between 2 curves? Is it a matter of checking each step in the segment (as lines)?

Additionally, is there a way to do a fast check on a "spaghetti" of splines to narrow down possible intersections? I looked into some variation of delaunay (at least the radial part) but it's not really suited.


what curves are you asking about? Bezier? are you looking for a solution for 2D intersection? before my answering the question... why do you need it?
 
Old 03 March 2011   #52
Originally Posted by Gravey: i know that Kameleon already posted a function for the finding the circumcenter of a triangle on the previous page, but to be honest I have no idea how it works, so I have written a different solution using barycentric coordinates:
fn circumcenter p1 p2 p3 = 
(
BC = distance p2 p3
CA = distance p3 p1
AB = distance p1 p2

baryCoords = [ (BC^2*(CA^2+AB^2-BC^2)), (CA^2*(AB^2+BC^2-CA^2)), (AB^2*(BC^2+CA^2-AB^2)) ]
triArea = baryCoords.x + baryCoords.y + baryCoords.z
baryCoords /= triArea -- normalize the barycentric coordinates
-- substitute in for P = uA + vB + wC
baryCoords.x * p1 + baryCoords.y * p2 + baryCoords.z * p3
)
References:
Circumcenter @ Wikipedia for the barycentric circumcenter forumla
6th post on this page for the formula to convert from barycentric to cartesian coordinates (P=uA+vB+wC)


You just made me laugh my heart out. Your function just shows the difference between a guy that knows shit about math (me) and one who does (you) lol

Cheers!
__________________
Artur Leao | Co-Founder / Project Manager
You can do it! VFX
Porto/Lisbon - Portugal
http://www.ycdivfx.com
 
Old 12 December 2011   #53
came across this thought it could be useful in this thread. sorry if it's been linked to before
 
Old 12 December 2012   #54
theres some very useful functions in PFActions_GlobalFunctions.cpp from the SDK can be found in maxsdk\samples\ParticleFlow\Actions.

some of functions include....

float MeshVolume(Mesh* mesh);
bool IsPointInsideMesh(Mesh* mesh, Point3 p);
bool ClosestPointOnMesh(const Point3& toPoint, Mesh* mesh, Point3& worldLocation, Point2& localCoords, int& faceIndex, float& dist2);
 
Old 12 December 2012   #55
Originally Posted by claude666: theres some very useful functions in PFActions_GlobalFunctions.cpp from the SDK can be found in maxsdk\samples\ParticleFlow\Actions.

some of functions include....

float MeshVolume(Mesh* mesh);
 bool IsPointInsideMesh(Mesh* mesh, Point3 p);
 bool ClosestPointOnMesh(const Point3& toPoint, Mesh* mesh, Point3& worldLocation, Point2& localCoords, int& faceIndex, float& dist2);

nice catch! thanks
 
Old 03 March 2013   #56
distance between points on a sphere

Ok this should be simple but clearly not this afternoon.

1. if we have a sphere with radius r
2. N# points evenly distributed across the sphere
3. What is the average distance between the points?

Thanks

-Michael
 
Old 06 June 2014   #57
View Space, World Space, Screen coords

as a reminder...

just found this useful post from Enrico Gullotti about screen coords, view space, world space :
http://forums.cgsociety.org/showpos...612&postcount=3

This helped me understanding how to draw freeform nodes on viewport.
Thanks a lot to him !
__________________
Rico)
=====================
 
Old 07 July 2014   #58
@All - Wonderful thread! Thank you CGTalk for keeping it open!

@ricozone - Thanks for sharing this link! Great addition to my collection and actually giving me some inspiration to tackle few scripting tasks that i got at work!
__________________
Thank you,

- stas
www.stascrash.com
 
Old 08 August 2014   #59
not a geometrical calc but a useful bit of math for export/import writers, posting it because it doesn't seem to be published anywhere on the web.

converting 3ds max glossiness to specular power

if glossiness in the 0-100 range (mxs)

if glossiness in the 0-1 range (sdk)
in reverse it would be...

if glossiness in the 0-100 range

Last edited by Klvnk : 11 November 2015 at 06:43 PM.
 
Old 11 November 2014   #60
thought i'd put this one here too, given an array of verts with a structure some thing like


and an array of face indices where there are 3 indices per face the following code will generate Tangents and Binormals

Last edited by Klvnk : 11 November 2015 at 06:44 PM.
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 04:54 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.