python - how to find a selected vert's symmetrical pair on a maya mesh -


what best (fastest) method find given vertex's symmetrical pair (ie , vert on left side of mesh , right hand side equivalent) possible use open maya api in python or there better way?

you don't want check position of every vert against every other on , over, extremely slow.

a simple approach hash value - simple comparison operation - every vertex identical 2 verts symmetrical. luckily tuples - not lists!! - hashable. algorithm be:

  1. get position tuple each vert
  2. make dictionary (position: vertex) verts on 'left' (or 'up' or 'back' etc) side.
  3. make second dictionary (position: vertex) verts on opposite side, symmetry axis flipped: if doing left/right axis, left list

    { (x, y, z) : "pcube1.vtx[0]" }  #etc  

    and right list

    { (-1 * x, y, z) : "pcube1.vtx[99]" } # , on 
  4. any key duplicated in both dictionaries symmetrical, need collect keys show in both , verts each side represent:

    duplicates = [j j in leftdictionary if j in rightdictionary] pairs = [leftdictionary[k], rightdictionary[k] k in keys]  

this won't super fast on big meshes should trick.

the 1 place may have issues if there floating point discrepancies between sides items visually symmetrical may not mathematically symmetrical. modify match numbers withing given tolerance by, say, quantizing values put tuples -- easy way blow them factor, 1000, , turn them integers. raw method errs on side of missing things symmetrical aren't exactly, quantized method may collapse multiple matches if close. i'd stick raw data unless it's failing need.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -