### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: How to detect Merged vertecies / vertexes on the same Edge line in a Polygon  (Read 2158 times)

#### Key-Real

• Sr. Member
• Posts: 362
##### How to detect Merged vertecies / vertexes on the same Edge line in a Polygon
« on: August 24, 2023, 10:36:23 am »
I render Polygons.
The situation is that I have a polygon which some vertexes are merged / vertex is on the same Edge Line, so i have a triangle.

Look at the image.
This Triangle is a 4 vertex Poly.

As it is, It will not pass the culling test and the rasterizer will drop this poly.

How to detect such vertecies?
« Last Edit: August 24, 2023, 12:07:50 pm by Key-Real »

#### wp

• Hero Member
• Posts: 12298
##### Re: How to detect Merged vertecies / vertexes on the same Edge line in a Polygon
« Reply #1 on: August 24, 2023, 12:25:30 pm »
Iterate over the four vertices and check for equality?

#### Key-Real

• Sr. Member
• Posts: 362
##### Re: How to detect Merged vertecies / vertexes on the same Edge line in a Polygon
« Reply #2 on: August 24, 2023, 12:34:07 pm »
yeh, that's what I'm fearing of.

I thought it would be a fast algorithm for that.

#### wp

• Hero Member
• Posts: 12298
##### Re: How to detect Merged vertecies / vertexes on the same Edge line in a Polygon
« Reply #3 on: August 24, 2023, 12:36:26 pm »
Why is it important to find duplicate vertices? In the function that you posted in the other thread, duplicate vertices would simply add zero to the sum.

#### Key-Real

• Sr. Member
• Posts: 362
##### Re: How to detect Merged vertecies / vertexes on the same Edge line in a Polygon
« Reply #4 on: August 24, 2023, 12:42:22 pm »
It still not working in some cases

see the image above

#### Key-Real

• Sr. Member
• Posts: 362
##### Re: How to detect Merged vertecies / vertexes on the same Edge line in a Polygon
« Reply #5 on: August 24, 2023, 04:52:41 pm »
The Culling doesn't work only in NDC Space,

if it is not about the topic problem, I don't knew

EDIT:
I had a DOT Product error in my calculations!
I edited my post at the
https://forum.lazarus.freepascal.org/index.php/topic,64376.0.html

thread,
now everything works fine
« Last Edit: August 24, 2023, 05:00:53 pm by Key-Real »

#### Key-Real

• Sr. Member
• Posts: 362
##### Re: How to detect Merged vertecies / vertexes on the same Edge line in a Polygon
« Reply #6 on: August 24, 2023, 04:59:25 pm »
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

PLEASE DELETE THIS THREAD!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!