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

 04 April 2008 arketip Frequenter   arketip Bruxelles, Belgium 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.) share quote
 09 September 2008 Gravey 3D Dude Joel Hewitt Sydney, Australia 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) share quote
 02 February 2009 SyncViewS IC.Developer   Enrico Gullotti Technical Artist and Programmer United Kingdom 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 share quote
 06 June 2009 alteredgene Veteran christian kim Auckland, New Zealand 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! share quote
 09 September 2010 duke Expert George Rolfe Newport, AU 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. share quote
 09 September 2010 denisT MAX Doctor   portfolio Denis Trofimov CA, USA 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? share quote
 03 March 2011 Kameleon Expert   portfolio Artur Leao Co-Founder / Project Manager You can do it! VFX Porto, Portugal 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 share quote
 12 December 2011 Klunk Lord of the posts   portfolio Klunk United Kingdom came across this thought it could be useful in this thread. sorry if it's been linked to before share quote
 12 December 2012 Klunk Lord of the posts   portfolio Klunk United Kingdom 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);`````` share quote
 12 December 2012 denisT MAX Doctor   portfolio Denis Trofimov CA, USA 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 share quote
 03 March 2013 spaw Veteran TD/Visual Effects 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 share quote
 06 June 2014 ricozone Veteran   portfolio Eric Bellanger CG artist Nantes, France 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) ===================== share quote
 07 July 2014 stascrash Frequenter   portfolio Stas Poritskiy Scripting/FX/Modeling/Texture/Post/ Gameloft Sydney, Australia @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 share quote
 08 August 2014 Klvnk Expert   portfolio Klunk United Kingdom 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. share quote
 11 November 2014 Klvnk Expert   portfolio Klunk United Kingdom 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. share quote

 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 vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.