Setting Orientation of a plane alongside a normal?

Software: Away3D 4.x

sentoplene, Newbie
Posted: 31 July 2013 12:43 PM   Total Posts: 25

Hi, I have a little problem…

I have already something set up where I read the normal of where I am with my mouse on a mesh…

But now I want to set the orientation of a plane alongside the normal, and I don’t know how to get there.

I think I need to do something with eulers and quaternions, but this is still a bit abacadabra for me.

This is my code:

private function handleMouseMoveevent:MouseEvent3D ):void 
{
 _mouseUV 
event.uv;

 
// Update tracers.
 
_locationTracer.position event.localPosition;
 
_normalTracer.position _locationTracer.position;
 
_iconPlane.position _locationTracer.position;
 var 
normal:Vector3D event.localNormal.clone();
 
normal.scaleBy50 );
   
 var 
lineSegment:LineSegment _normalTracer.getSegment) as LineSegment;
 
lineSegment.end normal.clone();
 
 
// here I want to set the _iconPlane alongside the normal, so in a 90 degrees angle of the hovered face
   

Avatar
GoroMatsumoto, Sr. Member
Posted: 31 July 2013 04:07 PM   Total Posts: 166   [ # 1 ]

You can get degrees for rotating on each axis from “Math.atan2”.

//rotationX:
var radX:Number Math.atan2(normal.ynormal.z);
var 
degX:Number rad Math.PI 180;

//rotationY:
var radY:Number Math.atan2(normal.znormal.x);
var 
degY:Number rad Math.PI 180;

//rotationZ:
var radZ:Number Math.atan2(normal.ynormal.x);
var 
degZ:Number rad Math.PI 180

I’m not sure that this code works correctly.
Please try it wink

Cheers.

   

beers, Member
Posted: 31 July 2013 05:27 PM   Total Posts: 53   [ # 2 ]

I’m lazy so I would just use a lookAt function. Copy the plane position to a vector3D, then add the normal to the vector3D, then use the lookAt function on your plane to aim it at the vector3D

beers

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X