Drawing a line perpendicular to a line on a plane whose normal is known
I have two vector(Vector3) positions of a line on a plane whose normal vector is known .What I am trying to do is draw a line perpendicular to this line on the same plane. Suppose end1 and end2 are two vectors representing the ends of the original line What I am trying right now :
var line1 = end1 + ( (end2-end1)* 1 );
var rotatedLine = Quaternion.AngleAxis( 90, anchor.transform.rotation*Vector3.up ) * end1;
//Debug.DrawLine(end2, rotatedLine, Color.blue);
var newLine1 = Instantiate(line );
LineRenderer lr2 = newLine1.GetComponent<LineRenderer>();
lr2.SetPosition(0,end1);
lr2.SetPosition(1,rotatedLine);
Answer by Hellium · Jul 09, 2018 at 02:28 PM
If the line belongs to the plane, it means this line is perpendicular to the normal.
So you are trying to find a new line perpendicular to the 1st line and to the normal.
You are looking for the cross product
Vector3 planeNormal = ... ;
Vector3 lineOnThePlane = ... ;
Vector3 result = Vector3.Cross( planeNormal.normalized, lineOnThePlane.normalized ) ;
Your answer
Follow this Question
Related Questions
Generating a plane in front of player infinitly 1 Answer
Why isn't my space ship rotating down with my mouse? 1 Answer
Plane.RayCast not hitting at all 0 Answers
Making a Line Renderer only visible to one Camera 1 Answer
How do I add points to a LineRenderer Width curve as I'm "drawing" the line? 0 Answers