MoI discussion forum
MoI discussion forum

Full Version: Rotate Array?

Show messages: All  1-8  9-15

From: Whiteman Dynamic (TIM_WHITEMAN)
6 Mar 2020   [#9] In reply to [#8]
@corchet

Haha! That's a great workaround! Thank you for your suggestion, I'll take a look... ;)
From: corchet
6 Mar 2020   [#10] In reply to [#9]














to join the leaves ... draw a third line in the middle ... with array ... 19 points on curve

the drawing of the leaves is made only with ' arc tri points ' easy to modify ( 1 bezier handle each ) ;)

and ' orient line line ' everywhere to finish
From: Michael Gibson
6 Mar 2020   [#11] In reply to [#6]
Hi Tim,

re:
> I did try adding the points back to the arrayed objects to have a point of reference
> for the rotations, but it didn't work, I suspect because the script is no longer seeing
> the result as a recently arrayed result?

If you tried this by deleting the line of code that removes the original points, yeah that won't work because you'll have an ordering of objects like:

Point
Point
Point
Obj
Obj
Obj

while these particular commands are expecting what you would get from an array which is arranged like:

Point
Obj
Point
Obj
Point
Obj

However, instead of keeping the original points it is possible to insert a new point, this can be done by adding in one strategic line of code.

Find the section of RotateArray.js that contains this code:

code:
			if ( Obj.isPointObject )
			{
				// Point objects have a "pt" property that gets the x,y,z point. Get that
				// as the rotation origin.
				OriginPt = Obj.pt;
			}
			else
			{
				// Not a point object, add it to the object list to be rotated.
				ObjectSet.addObject( Obj );
			}


and then add in this line of code indicated with >>>> <<<< (without the actual >>>> <<<< characters):


code:
			if ( Obj.isPointObject )
			{
				// Point objects have a "pt" property that gets the x,y,z point. Get that
				// as the rotation origin.
				OriginPt = Obj.pt;

>>>>				ObjectSet.addObject( Obj );     <<<<
			}
			else
			{
				// Not a point object, add it to the object list to be rotated.
				ObjectSet.addObject( Obj );
			}


With that in place a new point object will be created in the ordering that ScaleArray is expecting and so you should then be able to run the results from RotateArray through ScaleArray additionally.

I'll see about making a more generalized "TransformArray" in the future, it would make it a little easier if I implement a helper for it in the core MoI code.

- Michael
From: Frenchy Pilou (PILOU)
8 Mar 2020   [#12]
All that was in 2D or 3D? (you speak about "morphing between the two" )

There is also maybe the LineWeb (Michael) http://moi3d.com/forum/index.php?webtag=MOI&msg=3666.1
or CMorph (Max Smirnov) http://moi3d.com/forum/index.php?webtag=MOI&msg=6373.1
functions ... who can be help for some cases!


From: Mindset (IGNITER)
26 Feb   [#13] In reply to [#11]
Hello everyone,
I need the script to rotate, as it does, incrementally along the array to some maximum degree... but then also please, dwell (continue rotating by said maximum degree some additional elements, [perhaps by quantitative percentage] , and then decrement the rotational effect back down to none... i.e. leaving the last the element in the array result series to remain in its original orientation.
It would be nice if it could also have "Ease in/Ease out" control similar to that which is currently available under the "Limit to axis" option of the twist command.
I am most stymied, for the time being, by the dwell aspect of this perplexity; that is, how to serially rotate multiple array elements by said maximum degree.
Thanks,
MindSet
From: AlexPolo
26 Feb   [#14]
Hi The Scale Array script does something like this but cant seem to find it in the history of the forum.
Regards
Alex.
From: Michael Gibson
26 Feb   [#15] In reply to [#13]
Hi MindSet, you would need to modify the Update() function in the RotateArray.js script file to do that.

There is a line of code in there that calculates the parameter value from 0 to 1:

code:
var t = i / ( Factories.length - 1 );


You would need to put in some more code after that to modify the parameter with your desired behavior.

Here's an example that will step up the rotation along the first third, hold it for the middle third, and then ramp back down the last third. Put this in place of the current Update function:

code:
function Update( Factories, TotalRotationAngle )
{
	for ( var i = 0; i < Factories.length; ++i )
	{
		var t = i / ( Factories.length - 1 );

		////// Added section here
		{
			function SmoothStep( t )
			{
				// https://en.wikipedia.org/wiki/Smoothstep
				if ( t <= 0 ) return 0;
				if ( t >= 1 ) return 1;
				return t * t * (3 - 2*t);
			}

			function GetParam( t, low, high )
			{
				t = (t - low) / (high - low);
				return SmoothStep(t);
			}
		
			if ( t < 1/3 )
			{
				// Beginning third, ramp up smoothly from 0 to full rotation

				t = GetParam( t, 0, 1/3 );
			}
			else if ( t > 2/3 )
			{
				// Ending third, ramp down smoothly from full rotation to 0

				t = GetParam( t, 1, 2/3 );
			}
			else
			{
				// Middle range, hold at full rotation
				t = 1;
			}
		}
		////// End added section


		// Set the angle on the factory
		Factories[i].setInput( 2, t * TotalRotationAngle );
		
		// Update the factory to make it recalculate the rotated result.
		Factories[i].update();
	}
}

Show messages: All  1-8  9-15