You still haven’t defined north. But I’m going to assume by “north” you mean +y.
Now note, your expected results vs your results. You EXPECT to travel clockwise around the compass, but the results are traveling counter-clockwise.
If north is +y, and east is +x. And I told you the algorithm of x = Cos(theta), y = Sin(theta) results in a rotational direction from +x towards +y… that’d be a COUNTER-CLOCKWISE rotation. You expect the opposite direction.
Now, to resolve your problem. Instead of adjusting your angle, adjust your algorithm. We need a definition for calculating a vector that records 0 degrees pointing “north”, and 90 degrees pointing “east” (up and right respectively).
Sine is defined from 0-360 as going from 0 → 1 → 0 → -1 → 0 on a 90 degree interval
And Cosine from 0-360 as going from 1 → 0 → -1 → 0 → 1 on a 90 degree interval
We expect our y value to go from 1 → 0 → -1 and back as we rotate clockwise. This happens to be exactly what cosine does.
And we expect our x value to go from 0 → 1 → 0 → -1 → 0 as we rotate clockwise. This happens to be exactly what sine does.
SO:
y = Cosine(theta)
x = Sine(theta)
No need to add the 90 degrees to the angle or anything:
///<summary>
/// degrees is measured as an angle off Y+ (north) rotating clockwise towards X+ (East)
///</summary>
public static bool CastLine(float degrees, Vector2 start, float length)
{
float mRadians = (degrees * Mathf.Deg2Rad);
//I'm going to use UnityEngine.Mathf instead, it defaults to 'float' rather than 'double'
float mY = start.y + (length * Mathf.Cos(mRadians));
float mX = start.x + (length * Mathf.Sin(mRadians));
Vector2 mFinish = new Vector2(mX, mY);
Debug.DrawLine(start, mFinish, Color.blue, 1F, false);
RaycastHit2D mHit = Physics2D.Linecast(start, mFinish);
//why return true? it always returns true... what's the point?
return true;
}
Keep in mind that rotation is just a measure of the angle between two lines. When you talk about rotating an object, there’s more information… the direction of rotation, and off of what you’re rotating. It’s a multi-dimensional operation, yet you represent it in a 1-dimensional value. So thusly you need to include a definition of ‘no-rotation’, as well as a ‘direction’ of rotation.
And that’s what the algorithm we set is doing.
So I add it to the comments so anyone using the function understands what the angle ‘degrees’ is representing. With out that, one would probably assume the standard definition which is off +x towards +y.