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


#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