Greetings;
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;
}else{
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;
}