- Home /
Question by
Marco-I · Feb 25, 2020 at 01:22 PM ·
c#transform.positionmathlinerenderermathf
How to calculate inner vertices of a line renderer? (math question)
Hello guys, I would like to ask you a math question, if I can. :)
I have this:
I have the red line (generated with line renderer), and I've to generate the white line.
WHAT I KNOW: - Position of the vertices of the red line. - Position of the center vertex of the red line
WHAT I NEED TO KNOW/CALCULATE: - Position of the vertices of the white line.
Any help? Thank you.
Comment
Answer by elenzil · Feb 25, 2020 at 06:22 PM
here's a rough approach.
for each point:
calculate the inward-facing normal of each of the two line-segments touching the point.
eg, inNorm(p1, p2) = (p2 - p1).Normalize().Rotate90AboutZ().
add those two normals together.
normalize the resulting vector.
scale the resulting vector by whatever offset distance you want.
that's the new point position.