Convert 3D rotation to 2D rotation

A question for rotation experts (am talking to you Aldo or Mike!).

I have an aircraft flying in 3D space.

I wish to display an object on the minimap that is representative of this aircraft, but only rotated in 2D (y axis, fixed x and z).

I have written a script that works, but am not sure if this is the correct/optimal way of calculating this, as it works with the quaternions directly :

#pragma strict

var obj3d : Transform;
var obj2d : Transform;

var rot3d : Quaternion;
var rot2d : Quaternion;

function Update() 
{
	rot3d = obj3d.rotation;
	
	rot2d = Quaternion( 0.0, rot3d.y, 0.0, rot3d.w );
	
	obj2d.rotation = rot2d;
}

If there is a better method, please educate me !

=]

I’m worried that this won’t work for all Quaternions - because the .w is effectively helping define the actual axis of rotation so it will only work if that is a vertical axis - otherwise the Y rotation could actually be the Z rotation! (Or some weird combination of it).

What I’d do is just use the eulerAngles and take that version of Y because you know that is the rotation around a fixed axis.

  obj3d.rotation.eulerAngles.y = rot3d.eulerAngles.y

I wrote a bit of a tutorial on Quaternions on Unity Gems which does show this method (in C# unfortunately). C# doesn’t let you set a component of the eulerAngles individually - but I’m pretty convinced Unity Script does.