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


#49

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!


#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.


#51

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?


#52

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!


#53

came across this thought it could be useful in this thread. sorry if it’s been linked to before


#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);

#55

nice catch! thanks


#56

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


#57

as a reminder…

just found this useful post from Enrico Gullotti about screen coords, view space, world space :
http://forums.cgsociety.org/showpost.php?p=5165612&postcount=3

This helped me understanding how to draw freeform nodes on viewport.
Thanks a lot to him !


#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!


#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


#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


#61

Hi Klvnk,

very interesting functions. As i’m not familiar with geometry data structure, can you please give a usage example ?
How to build a struct vertex for any given mesh ?
I was thinking about that :

- sm = snapshotasmesh (Teapot())
- loop through each vert and get :
    p = meshop.getvert sm v
    n = getnormal sm v
    col = -- vertex color ?
    uvw1 = getTVert sm <tvert_index_integer> -- how to get tvert from current vert ?
- build array of faces indices :
    fi = for f=1 to sm.numfaces collect ((meshop.getVertsUsingFace sm f) as array)
- once i got my vertex array struct, i can call your functions :
ComputeTangents myVertStruct fi

Sorry if i bother with noob question


#62

yep that kind of thing will do it, I’ll start a new thread with an example.


#63
yep that kind of thing will do it, I'll start a new thread with an example.

thanks !

http://forums.cgsociety.org/showthread.php?f=98&t=1233324


#64

randomize a normal…


#65

simple but was quite tricky to find…

pos is the position of the base of the cone and pnt is the position of the point on the cone, r & h are the radius and height respectively


#66

:thumbsup: :applause: :applause:


#67

I apparently annoyed the wrong people on stackoverflow so perhaps i’ll get more joy here. If I have a plane in the YZ plane and want to project it onto a sphere, what equation do I use for the X axis?


#68

one more modification :wink:

fn rotatePointAroundCenter center dir radius steps:8 debug:false = (


	local tm = (matrixFromNormal dir)
	local p = center+(tm.row1*radius)
	local div = 360/steps
	local points = for i = 0 to (360 - div) by div collect (

		local q = quat i (normalize dir)
		(((p - center ) * q) + center)
	)
	if debug do for p in points do point pos:p dir:dir wirecolor:green
       points 
)
rotatePointAroundCenter $Box011.pos $Box011.dir 20 debug:true