Get/Calular edges of a 3D object

Asked

Viewed 31 times

2

I have the following question regarding obtaining the positions of a certain edge of a 3D object.

Example, I have a track (car game) and I want to calculate, through a script C#, both sides of the track. See image:

inserir a descrição da imagem aqui

I have the positions of all the vertices (which also exist in the center of the track), but I want the vertices that are only at the limits of the track.

Does anyone know which calculation I should use?

  • Apparently I think it’s safe to ignore the Z axis, leaving only X and Y. Am I right? This greatly diminishes what needs to be sought, not to mention that I have an answer with part of your need (convex wrap). Not the best for your case (I would ignore the concavities of the curves), but it is something

1 answer

0

With the data you provided it seems impossible to solve the problem, however if the track has constant width (or you can know the width of the track at a given vertex) there is a solution.

At each vertex you will check if there is any other vertex at a distance of a clue. An example follows::

Vertices[] arrayVertices;
float larguraDaPista = 5;
for(int i = 0; i < arrayVertices.size(); i++){
    Vertice verticeATestar = arrayVertices[i];
    for(int j = i; j < arrayVertices.size(); j++){
        Vertice verticeParaComparar = arrayVertices[j];
        if (Vector3.Distance(verticeATestar, verticeParaComparar) == larguraDaPista){
        //São ambos limites
        }
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.