Jump to content

Reverse Node for Vector to angle?


Recommended Posts

Hi,

 

I have to move some objects in an angle but i only got vectors, so i dont know how to calculate a vector out of an angle and there is only "vector to angle" node.

 

 

MAybe someone has a reverse node or knows how this goes better with different nodes.

 

I have a list of path extruded rectangles along lines, which generated out of a polyline (red).

 

image.png.f8176d1480d32119e5b2d7b2a2a57871.png

 

But the profile which is extruded allways is "placed" in the middle (center of bounding box) of my path extrude.

 

But I need this extrudes BEHIND or INFRONT the line (The Profil has to be extruded in the edge of my ).

 

image.thumb.png.3ec369a15e5c3df8c67d0df9f6cc091d.png

So i thought i can read out a list of angles of the lines and use the "MOVE" node to move the Boxes half height and half width.

 

But the node needs a vector not an angle.

 

BR KC

Extrusionsbauteil_Version_2.vwx

Edited by KingChaos
Link to comment

Hello,

 

there is a VS Function that converts an angle into a vector. You can look it up here.

 

With that Function you can write your own Marionette Node. In Python it could look something like this:


@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
	#Name
	this = Marionette.Node( 'Angle to Vector' )
	this.SetDescription( 'Converts an angle in degrees to a 2D vector' )

	#Input Ports
	nAngle = Marionette.PortIn(0) 
	nAngle.SetDescription( 'an angle in degrees' )
	
	nLength = Marionette.PortIn(1) 
	nLength.SetDescription( 'the length of the output vector' )
	
	#OIP Controls

	#Output Ports
	v = Marionette.PortOut()  
	v.SetDescription( 'a 2D vector' )

#BEHAVIOR
	
def RunNode(self):	 
	#inputs
	nAngle = self.Params.nAngle.value
	nLength = self.Params.nLength.value

	#script
	v = vs.Ang2Vec(nAngle, nLength)
	
	#outputs
	self.Params.v.value = v

 

But, as shown in the example below, in some cases the VS function returns realy small numbers instead of zeros. So i would recommend to round the returned values to a reasonable length.

grafik.thumb.png.61401937d07ab3c2190ecdf4502b96cf.png

Edited by Letti R
  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...