Notifications
Clear all

[Closed] Vertex index from vertex positions?

Hi there…I am tring to find a way to calculate vertices indexes given their positions?is there any way?thank you!!!

3 Replies

maybe you can cache hash values of their positions and then check if hash of such position exists?
the only question is how to minimize hash collisions when different values produce equal hashes

(
	delete objects
	t = Teapot()
	convertToMesh t

	vert_pos_hashes = for i=1 to t.numverts collect 
	(
		v = GetVert t i
		getHashValue ( v.x * 5 + v.y * 3 + v.z ) 0
			
	)

		
	v102 = GetVert t 102
	hashValue = getHashValue ( v102.x * 5 + v102.y * 3 + v102.z ) 0
	for i=1 to vert_pos_hashes.count where vert_pos_hashes[i] == hashValue do print i
		
	findItem vert_pos_hashes hashValue
)

working with floats (in your case with three floats (x,y,z)) you should understand that there is some epsilon accuracy. so you have to check not ‘exact’ position but probably ‘close enough’. that means instead of ‘exact’ position check the distance to the position (which must be less than specified).

thnx fo your help!!!i’ll try