Advertisement

Calculating Cylinder Width and Radius

Started by January 15, 2016 06:43 PM
1 comment, last by Alundra 8 years, 9 months ago

I have vertices array which contains the positions for a cylinder mesh.

How do I calculate the cylinder width and radius from this vertices?

Is the mesh already standing upright? If so you can find the height/diameter with length( max - min ) of the verts. Otherwise I suppose you could do PCA to find a basis to aligned the cylinder along the cartesian axes, and do the same length( max - min ) where max and min are calculated along the basis axes.

From wikipedia:

220px-GaussianScatterPCA.png
The vectors shown are the eigenvectors of the
covariance matrix scaled by the square root of the corresponding eigenvalue, and shifted so their tails are at the mean.
Advertisement

On the same road as Randy Gaul said, if I understand correctly what you ask :

1) Simply for loop each vertice and find the min/max on the x axis and y axis.

2) Radius = 0.5f * (m_Max.x - m_Min.x)

3) Height = m_Max.y - m_Min.y

This topic is closed to new replies.

Advertisement