# Mesh projection on plane ❓

I need to project a mesh and a line on a plane (let’s say XY) according to a random direction vector (simplest case is when it’s normal to XY). Then I need to find 2 intersection points of the border of the projected figure and (extended) projected line. How can I do that?

I did find how to project a line on a plane, but what about mesh? How do I find intersection points once I can find a projection?

Welcome aboard!

It seems more of a math question than a Babylon question to me. Maybe you would have more luck in a math forum?

Also, is your mesh of any shape? Or is it a sphere? If it can be any shape, what means `2 intersection points of the border of the projected figure`? The projection could be any shape, so the line could intersect 0, 1, 2 or more times the projected mesh.

Adding @JohnK, our Math guru here.

Not something I have much experience of. In some ways the on screen view of a mesh is its projection in 2D space.

You could maybe use these on the vertex positions

1 Like

Yes, you right, since projection won’t always be a convex set, I’d get 0, 1, 2, or more intersection points. But in my case, I can be sure there are at least 2, and if more, I’d just take two points which farthest apart.

Thanks!

Based on these links, I’ve ended up with a slightly different solution:

• Took all vertex positions of the mesh and project them onto a plane
• Made an extrusion of projection:
``````  const shape = [...projection];
shape.push(shape[0]); //close profile
const path = [new Vector3(0, 0, -100), new Vector3(0, 0, 100)];
const extrusion = MeshBuilder.ExtrudeShape('', { shape, path, sideOrientation: Mesh.DOUBLESIDE });
``````
• So I’ve made something I call “ugly cylinder” (imagine extrusion of randomly connected dots on a surface)
• Then I took initial line as a vector, and found 2 points of intersection with “ugly cylinder” using raycasting.

Ideally, I’d find a border of that projection, and get something close to the regular cylinder, but I’ve found that too complicated.

Still feel like I’ve reinvented the wheel, but it works.