Calculate third Vector3 with two Vector3s and an Angle


I’m trying to accomplish the finding myPointC, see comments to see where I need help with. The rest of the code works as intended. The function I’m having a problem with is how to find using an angle. The line length does not even need to be here as it’s not really an issue because I know that value.

the basic is find pointC relative to pointA using pointA, pointB and an Angle.

Here is a image for a visual question if this can help you any. I’m pulling my hair out over this, even though I’m already bald:

private void DrawLineUsingDistanceAtAngle(){
		Vector3 myPointA;
		Vector3 myPointB;
		Vector3 myPointC;
		float lineAngle = 15f;
		float lineLength = 10f;
		myPointB = LerpByDistance(myPointA, myPointB, lineLength);
		myPointB = GetThirdVector3UsingAngle(
				myPointA, myPointB, lineAngle, "x");
		DoSomethingGreat(myPointA, myPointB);
	private Vector3 GetThirdVector3UsingAngle(
			Vector3 pointA, Vector3 pointB, 
			float angle, string zeroAxis = "z")
		Vector3 pointC;
		if (zeroAxis == "x"){
			pointA.x = 0;
			pointB.x = 0;
		}else if(zeroAxis == "y"){
			pointA.y = 0;
			pointA.y = 0;
			pointA.z = 0;
			pointA.z = 0;
		// do calculation to get pointC here
		return pointC;
	public Vector3 LerpByDistance(Vector3 A, Vector3 B, float x)
    	Vector3 P = x * Vector3.Normalize(B - A) + A;
		return P;

Take that top line AB, rotate it by the angle, then rescale for the correct length. I’m going to assume this is a top view, so the rotation is over Y. I think you have it all except the actual rotate, but including it all for context:

Vector3 B2 = B-A; // move line AB to come out of (0,0,0) so rotate is easier
Quaternion angleSpin = Quaternion.Euler(0,angle,0); // create a rotation out of angle
Vector3 C2 = angleSpin * B2; // rotate AB by the angle

// C2 is now facing the correct way, but coming out of (0,0,0) and the wrong len:
C = C2.normalized * cLen + B; // rescale, recenter coming out of A