[vtkusers] moving cells 1/2 cm

Jochen K. jochen.kling at email.de
Sat Jun 16 01:45:09 EDT 2012


Hi,


1. First you have to find the center point of your cell C (which is a
triangle).

The triangle vertices are named p1, p2 and p3 and the center of the triangle
c:

cx = (p1x + p2x + p3x) / 3
cy = (p1y + p2y + p3y) / 3
cz = (p1z + p2z + p3z) / 3

2. Next we have to find the parametric form of the line equation being
defined by c and each of it's vertices:
I'll do it for one vertice(for instance p1), okay?

px = cx + (p1x - cx) * m
py = cy + (p1y - cy) * m
pz = cz + (p1z - cz) * m

3. now calculate the distance betwen p1 and c:

d = sqrt((p1x - cx)*(p1x - cx) + (p1y - cy)*(p1y - cy) + (p1z - cz)*(p1z -
cz))

4. the coordinates for the vertice to find:

px = cx + (p1x - cx) * (d+0.5)/d
py = cy + (p1y - cy) * (d+0.5)/d
pz = cz + (p1z - cz) * (d+0.5)/d

You can easily proof that this equation is correct. Say 0.5 would be zero.
Then you would receive exactly p1. Say 0.5 would be -d: Then you get the
center coodinates. Right?


repeat step 2, 3 and 4 for the other two points to find (p2 and p3).

with best regards
Jochen


--
View this message in context: http://vtk.1045678.n5.nabble.com/moving-cells-1-2-cm-tp5713928p5713943.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list