<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl3%3ACommunity%3Ascripting%3Acustom_helper_scripts%3Ahelper_rotation</id>
	<title>Hpl3:Community:scripting:custom helper scripts:helper rotation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl3%3ACommunity%3Ascripting%3Acustom_helper_scripts%3Ahelper_rotation"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl3:Community:scripting:custom_helper_scripts:helper_rotation&amp;action=history"/>
	<updated>2026-05-15T10:52:12Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl3:Community:scripting:custom_helper_scripts:helper_rotation&amp;diff=89&amp;oldid=prev</id>
		<title>Maintenance script: Upload from wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl3:Community:scripting:custom_helper_scripts:helper_rotation&amp;diff=89&amp;oldid=prev"/>
		<updated>2020-07-09T13:41:58Z</updated>

		<summary type="html">&lt;p&gt;Upload from wiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=helper_rotation.hps=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Returns the rotation of an entity in euler angles.&lt;br /&gt;
 * &lt;br /&gt;
 * @param asEntityName, The name of the entity.&lt;br /&gt;
 * @return cVector3f, The rotation of the entity in euler angles, in the order (X, Y, Z). Returns a zero vector if the entity was not found. &lt;br /&gt;
 **/&lt;br /&gt;
cVector3f Entity_GetRotationEuler(const tString &amp;amp;in asEntityName)&lt;br /&gt;
{&lt;br /&gt;
	iLuxEntity @ent = cLux_GetCurrentMap().GetEntityByName(asEntityName);&lt;br /&gt;
	if (ent is null) return cVector3f_Zero;&lt;br /&gt;
&lt;br /&gt;
	return cMath_MatrixToEulerAngles(ent.GetMatrix().GetRotation());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Sets the rotation of an entity using euler angles.&lt;br /&gt;
 * &lt;br /&gt;
 * @param asEntityName, The name of the entity.&lt;br /&gt;
 * @param avEulerAngles, The rotation to set the entity to, given in euler angles in the order (X, Y, Z).&lt;br /&gt;
 **/&lt;br /&gt;
void Entity_SetRotationEuler(const tString &amp;amp;in asEntityName, cVector3f avEulerAngles)&lt;br /&gt;
{&lt;br /&gt;
	iLuxEntity @ent = cLux_GetCurrentMap().GetEntityByName(asEntityName);&lt;br /&gt;
	if (ent is null) return;&lt;br /&gt;
&lt;br /&gt;
	cMatrixf mTransform = ent.GetMatrix();&lt;br /&gt;
	cMatrixf mRot = cMath_MatrixRotateXYZ(avEulerAngles);&lt;br /&gt;
	mTransform.SetRotation(mRot);&lt;br /&gt;
	ent.SetMatrix(mTransform);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Adds the given euler angles to the current rotation of an entity.&lt;br /&gt;
 * &lt;br /&gt;
 * @param asEntityName, The name of the entity.&lt;br /&gt;
 * @param avEulerAngles, The rotation to add to the entity, given in euler angles in the order (X, Y, Z).&lt;br /&gt;
 **/&lt;br /&gt;
void Entity_RotateEuler(const tString &amp;amp;in asEntityName, cVector3f avEulerAngles)&lt;br /&gt;
{&lt;br /&gt;
	cQuaternion rot = Entity_GetRotation(asEntityName);&lt;br /&gt;
	rot = cMath_QuaternionMul(rot, cMath_QuaternionEuler(cVector3f(avEulerAngles.x, 0, 0), eEulerRotationOrder_XYZ));&lt;br /&gt;
	rot = cMath_QuaternionMul(rot, cMath_QuaternionEuler(cVector3f(0, avEulerAngles.y, 0), eEulerRotationOrder_XYZ));&lt;br /&gt;
	rot = cMath_QuaternionMul(rot, cMath_QuaternionEuler(cVector3f(0, 0, avEulerAngles.z), eEulerRotationOrder_XYZ));&lt;br /&gt;
	Entity_SetRotation(asEntityName, rot);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Returns the rotation of an entity.&lt;br /&gt;
 * &lt;br /&gt;
 * @param asEntityName, The name of the entity.&lt;br /&gt;
 * @return cQuaternion, The rotation quaternion of an entity. &lt;br /&gt;
 **/&lt;br /&gt;
cQuaternion Entity_GetRotation(const tString &amp;amp;in asEntityName)&lt;br /&gt;
{&lt;br /&gt;
	iLuxEntity @ent = cLux_GetCurrentMap().GetEntityByName(asEntityName);&lt;br /&gt;
	if (ent is null) return cQuaternion_Identity;&lt;br /&gt;
&lt;br /&gt;
	return cMath_QuaternionMatrix(ent.GetMatrix().GetRotation());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Sets the rotation of an entity.&lt;br /&gt;
 * &lt;br /&gt;
 * @param asEntityName, The name of the entity.&lt;br /&gt;
 * @param aRotation, The rotation to set the entity to.&lt;br /&gt;
 **/&lt;br /&gt;
void Entity_SetRotation(const tString &amp;amp;in asEntityName, cQuaternion aRotation)&lt;br /&gt;
{&lt;br /&gt;
	iLuxEntity @ent = cLux_GetCurrentMap().GetEntityByName(asEntityName);&lt;br /&gt;
	if (ent is null) return;&lt;br /&gt;
&lt;br /&gt;
	cMatrixf mTransform = ent.GetMatrix();&lt;br /&gt;
	cMatrixf mRot = cMath_MatrixQuaternion(aRotation);&lt;br /&gt;
	mTransform.SetRotation(mRot);&lt;br /&gt;
	ent.SetMatrix(mTransform);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Adds the given rotation to the current rotation of an entity.&lt;br /&gt;
 * &lt;br /&gt;
 * @param asEntityName, The name of the entity.&lt;br /&gt;
 * @param aRotation, The rotation to add to the entity.&lt;br /&gt;
 **/&lt;br /&gt;
void Entity_Rotate(const tString &amp;amp;in asEntityName, cQuaternion aRotation)&lt;br /&gt;
{&lt;br /&gt;
	cQuaternion rot = Entity_GetRotation(asEntityName);&lt;br /&gt;
	rot = cMath_QuaternionMul(rot, aRotation);&lt;br /&gt;
	Entity_SetRotation(asEntityName, rot);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
		
	</entry>
</feed>