# Draw af line in a specific angle around an object

Hi. I have a transform which I can draw a Ray from using e.g. Gizmos.DrawRay. My problem is that I don’t know how to define an angle instead of a direction.

E.g. I can understand that transform.forward - transform.right will send it 90 degrees to the left - but how do I say “draw a line in 12 degrees to the right of transform.forward”?

With regards
mpark

You can rotate the line segment by 12 degrees, using a quaternion (Angles are made with Quaternions.) To make a 12 degree y-rotation, use: `Quaternion y12degs = Quaternion.Euler(0,12,0);` The result, `y12degs` can be used to “hit” any Vector3 and spin it. So:

``````Vector3 lineEnd = transform.forward;
// NOTE: lineEnd is a short line acting as if I was at (0,0,0)

Quaternion y12degs = Quaternion.Euler(0,12,0);
// This is odd. You apply the 12 degree rotation to a point by multiplying:
lineEnd = y12degs * lineEnd;

// bring it back to world coords:
// NOTE: if line should be longer, scale it anytime before this
lineEnd = lineEnd + transform.position;
``````

There are lots of special purpose functions for doing this. But using quaternions is just one trick to learn that can solve just about anything, and is at worst only a little longer than some “cool” way.