Matching Axis from Position points

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2013   #16
In order to find the center of the bounding box isn't hard to do, just a pain to do.

If the Z is to be flipped direction wise do I just Invert the Up?


Thank you Denis for your help on this. I appreciate it.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 04 April 2013   #17
Originally Posted by JokerMartini: In order to find the center of the bounding box isn't hard to do, just a pain to do.

If the Z is to be flipped direction wise do I just Invert the Up?


Thank you Denis for your help on this. I appreciate it.

Why is the pain, you can always use
selection.center
__________________
Looking in the right side. [bgaTools]
 
Old 04 April 2013   #18
Originally Posted by gazybara: Why is the pain, you can always use
selection.center


What if all you have is point3 values and not actual max objects.....
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 04 April 2013   #19
Originally Posted by JokerMartini: In order to find the center of the bounding box isn't hard to do, just a pain to do.

it's not hard if you know coordinate system for the bounding box. but in most cases you don't know. and have to find the best (where the bounding box is optimal)... this is hard.
If the Z is to be flipped direction wise do I just Invert the Up?

invert UP or do cross product for (v2 v1) instead of (v1 v2). both things do the same.
 
Old 04 April 2013   #20
Originally Posted by gazybara: Why is the pain, you can always use
selection.center

generally we are talking about positions, not about nodes. that's the one...
the two is the selection center is always in the world coordinate system. which is not always desired.
 
Old 04 April 2013   #21
See the '2d' section here, it might help: https://en.wikipedia.org/wiki/Minim..._box_algorithms

"It is based on the observation that a side of a minimum-area enclosing box must be collinear with a side of the convex polygon"

Judging by your image you only have 6 options to check.. pick the smallest one.

sounds like a nice mini challange
__________________
The GPU revolution will not be rasterized! - http://www.jdbgraphics.nl
 
Old 04 April 2013   #22
Originally Posted by denisT: what i calculate calls physical center (or center of mass). you are talking about geometrical center (center of bounding box)

I thought, that the centroid was the geometric center, and,
it coincides with the center of mass if the density is homogeneous ?

http://en.wikipedia.org/wiki/Centroid

.
__________________
may not be following this thread.
.
 
Old 04 April 2013   #23
Originally Posted by denisT: it's about Z vector... if way from point1 to point2 is CW Z(up) vector will look Up, if CCW it will look Down... or inversely...

How do ypu check if its clockwise it ccw?
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 04 April 2013   #24
Originally Posted by jonadb: See the '2d' section here, it might help: https://en.wikipedia.org/wiki/Minim..._box_algorithms

"It is based on the observation that a side of a minimum-area enclosing box must be collinear with a side of the convex polygon"

Judging by your image you only have 6 options to check.. pick the smallest one.

sounds like a nice mini challange

2d solution sounds easy, but... it's just for convex geometry. try to find shortest edge of convex hull for random cloud of points...
 
Old 04 April 2013   #25
Originally Posted by JokerMartini: How do ypu check if its clockwise it ccw?

to know that you have to define a system coordinates... if it's WORLD the dot product of world-up ([0,0,1]) and your Up vector has to be positive or negative depending on CW or CCW.
 
Old 04 April 2013   #26
Here is my function for a flat spline on xy plane, I think you can rewrite it easily. positive or negative output tells you its direction.

There are 2 methods.. I think officially it's just adding all the cross-products between the segments, if the total it < 0 then it's CCW and > 0 it's CW (or the other way around. can't remember)

Btw, max internally uses as slight variation on this when using the applyOffset function on a spline, it counts the positive vs negative cross product vectors to determine it's direction. Since I used below function for splineoffsets I copied that behavior, not sure which one it the correct one.



fn getDirection sp =
		(
		 
			for s = 1 to (numSplines sp) do
				(
					
				vec=0
				k=1	

				nr=	numKnots sp s
				while ( k < (numKnots sp s)) do
				(

					p1=getKnotPoint sp s k
					p2=getKnotPoint sp s (1+mod (k) nr)
					p3=getKnotPoint sp s (1+mod (k+1) nr)
					
					t=cross (p3 - p2) (p1 - p2)
					
					if (t[3]>0) do
					(
					vec=vec+1
					)
					
					if (t[3]<0) do
					(
					vec=vec-1
					)
					
					k=k+1
				)
                         )
		    vec
		)
__________________
The GPU revolution will not be rasterized! - http://www.jdbgraphics.nl

Last edited by jonadb : 04 April 2013 at 01:20 PM.
 
Old 04 April 2013   #27
Math wiz help


Math wiz help.

So now that we have part of this working. What you see on the left is what the current srcipt below does.

How do I then take the newly created TM generated by
(multipointTM ptsArr) 


And create two more rows of verts/points aligning them in the same orientation so the '1' are all in a column and so on.

The sample in the right of the image is the correct result I'm after. Keep in mind these are point3's not actual objects. So linking and parenting hacks wouldn't work in this scenario.





(
	delete objects
	
	local columns = 6
	local columnAngle = 360.0 / columns
	local radius = (units.decodevalue "20.0cm")
	local radiusB = (units.decodevalue "25.0cm")
	local master = point pos:[0,0,0]
	local ptsArr = #()
	local posArr = #()
	
	fn multipointTM points = if points.count > 1 do
	(
		center = [0,0,0]
		for p in points do center += p.pos
		center /= points.count

		front = normalize (points[1].pos - center)
		side = normalize (points[2].pos - center)
		up = normalize (cross front side) -- orthogonalized up
		side = normalize (cross up front) -- orthogonalized side
		tm = matrix3 front side up center
	)
	
	for c = 1 to columns do
	(
		calcX = radius * cos((c-1) * columnAngle)
		calcY = radius * sin((c-1) * columnAngle)
		
		pos = [calcX,calcY,40]
		pt = text text:(c as string) pos:pos size:5 wirecolor:green parent:master
		append ptsArr pt
	)
	rotate master (AngleAxis (random -360 360) [1,1,1])
	delete master

	p = point size:10 axistripod:on transform:(multipointTM ptsArr) wirecolor:yellow	
	
	
	
	--Now generate 2 rows of verts using the new TM
	steps = 2
	for s = 1 to steps do
	(
		for c = 1 to columns do
		(
			calcX = radiusB * cos((c-1) * columnAngle)
			calcY = radiusB * sin((c-1) * columnAngle)
			
			pos = [calcX,calcY,(5*s)]
			pt = text text:(c as string) size:5 wirecolor:blue pos:pos
			append ptsArr pt
		)
	)
)
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 04 April 2013   #28
Maybe a stupid question but why don't you use dummy geometry?

-redraw off
-generate geometry
-use all of max's clever build-in transform stuff
-extract TM
-delete dummy
-redraw on
-profit
__________________
The GPU revolution will not be rasterized! - http://www.jdbgraphics.nl
 
Old 04 April 2013   #29
pt.transform = masterTM * pt.transform
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 04 April 2013   #30
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed 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 01:05 PM.


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