Jump to content

Rotate: Difference between revisions

139 bytes added ,  21 May 2024
m
Put image to infobox, and edit a few paragraphs and files
(Created page with "Rotates vector by a rotation. File:Rotate.png == Example == You can move a block to the direction that it's facing. Since the arrow is facing up by default, the velocity of the arrow should be upwards (0, 0, 0.1). To get the velocity of the block if it's not facing up, we can rotate the velocity (0, 0, 0.1) by the block's rotation. To move the block, we just add the block's position and the velocity and set that to the block's new position. File:Screenshot_202...")
 
m (Put image to infobox, and edit a few paragraphs and files)
Line 1: Line 1:
Rotates vector by a rotation.
{{Block
|image=Rotate.png
|type=s
|folder=Math
|input1={{Port|v|Vec}}
|input2={{Port|r|Rot}}
|output1={{Port|v|Rot * Vec}}
}}


[[File:Rotate.png]]
Rotates [[vector]] by a [[rotation]].


== Example ==
== Example ==
Line 7: Line 14:
You can move a block to the direction that it's facing.
You can move a block to the direction that it's facing.


Since the arrow is facing up by default, the velocity of the arrow should be upwards (0, 0, 0.1). To get the velocity of the block if it's not facing up, we can rotate the velocity (0, 0, 0.1) by the block's rotation. To move the block, we just add the block's position and the velocity and set that to the block's new position.
Since the arrow is facing up by default, the velocity of the arrow should be upwards (<code>0, 0, 0.1</code>).
To get the velocity of the block if it's not facing up, we can rotate the velocity by the block's rotation.
To move the block, we just add the block's position and the velocity and set that to the block's new position.


[[File:Screenshot_20210206-121736_Fancade.jpg]]
[[File:Rotate_arrow_movement.jpg]]


With the Rotate block, we can also rotate a block around a pivot, instead of just the center of block itself.
With the Rotate block, we can also rotate a block around a pivot, instead of just the center of block itself.


To rotate the block around a pivot, we would rotate the vector from the pivot to the block's starting position (not the current position). Make sure you add the result with the pivot before setting it to the block's new position, otherwise it would end up rotating around (0, 0, 0). Setting the pivot's rotation to the block's rotation is to make it rotate around the pivot instead of circling around it without changing rotation.
To rotate the block around a pivot, we would rotate the vector from the pivot to the block's starting position (not the current position).
Make sure you add the result with the pivot before setting it to the block's new position, otherwise it would end up rotating around the origin point, <code>0, 0, 0</code>.
Setting the pivot's rotation to the block's rotation is to make it rotate around the pivot instead of circling around it without changing rotation.


[[File:Screenshot_20210113-094731_Fancade.jpg]]
[[File:Rotate_pivoting.jpg]]


== Related ==
* [[Scale]]


[[Category:Blocks]]
[[Category:Blocks]]