01 January 2013  
Expert
portfolio
Jeremy Raven
Wellington,
New Zealand

iterating through 2 inputMeshes
Hi there,
Im making a plugin where I want to compute the velocity of points on a mesh that are deforming. So I have an input for the meshOriginal and another for the finalMesh. The problem is the logic I am using, I know its just wrong but I can think of another way to do it. Currently I believe I am grabbing the first point on mesh1 and then computing it with every point on mesh2, once thats done the same thing happens for the second point. This is wrong. All I want to do is to compute mesh1Point1 with mesh2Point1, then mesh1Point2 with mesh2Point2 etc etc. Heres the code I have so far, any help would be grateful.
__________________
Vimeo Last edited by Aikiman : 01 January 2013 at 06:45 AM. 
01 January 2013  
Expert
portfolio
Burkhard Rammner
bioinformatition
med.uni.goettingen/sciloop
Hamburg,
Germany

I`m not sure if I understood your question.
If you want interactive feedback you should save the position of every vertex for every evaluation cycle and compare the last with the current position. Is it that what you want? 
01 January 2013  
A newbie
portfolio
Zohar
Wellington,
New Zealand

The norm of each vector divided by the time would give you the velocity. 
01 January 2013  
Expert
portfolio
Jeremy Raven
Wellington,
New Zealand

Originally Posted by zoharl:
The norm of each vector divided by the time would give you the velocity. Ahh simple as that thank you but now I realise my method is wrong. I need the point position from the current frame and the frame before rather than use the meshShapeOrig as input  silly mistake. Ill give that a go now. Can you explain a bit more about the norm of each vector? Do you mean the normalised vector result of point2point1? What about the magnitude? __________________
Vimeo 
01 January 2013  
A newbie
portfolio
Zohar
Wellington,
New Zealand

Norm is the magnitude (L2 norm of a vector equals to the vector's length). Normalizing a vector means dividing it by its norm (and then its norm  length  is 1).
http://mathworld.wolfram.com/VectorNorm.html 
01 January 2013  
A newbie
portfolio
Zohar
Wellington,
New Zealand

I had a power failure (I live in a banana republic...), so I didn't finish editing my post.
About the velocity. The norm of the vector would give us the distance between two points, so we have the distance as a function of time. From elementary school, we know that the derivative of the distance function (w.r.t. time) is the velocity. You have samples of the distance functions (as the vertices of your meshes), and you want to approximated the derivative of the distance function using finite difference. But first you need specify where/when (in which point in space or time) do you want to calculate the velocity. . In you first post you suggested approximating the velocity with forwarddifference of order 0: (x_{t+1}x_t), where \Delta t, the time step, is 1. In the previous post you suggested to approximate the velocity using centraldifference of order 0: (x_{t+1}x_{t1})/2. You can actually use more samples (as much as you like), and raise the approximation order (how precise your estimation is), by plugging your samples into the appropriate formula: http://en.wikipedia.org/wiki/Finite_difference But I didn't try this in practice, so you should ask someone from dynamics how crucial the order of approximation is. 
01 January 2013  
Expert
portfolio
Jeremy Raven
Wellington,
New Zealand

Okay I was getting myself confused with norm and normalize for a moment. Unfortunately math isnt my strong point, I understand basic trig and vector math but calculus  forget it
__________________
Vimeo 
01 January 2013  
A newbie
portfolio
Zohar
Wellington,
New Zealand

You implied it was too simple...
Never mind, do it like your intuition tells you. Divide the length (distance) by the time, and you get the velocity. 
01 January 2013  
Expert
portfolio
Jeremy Raven
Wellington,
New Zealand

Ill give myself a couple of points for the enthusiasm
Thanks for your help. __________________
Vimeo 
01 January 2013  
Expert
portfolio
Jeremy Raven
Wellington,
New Zealand

Okay Ive given this a few more moments of thought in between other projects. If the evaluation of velocity happens every frame that would mean time is constant right, ie every frame? That would mean all I need is the distance per frame ie point2  point1 as in the above code you supplied earlier?
__________________
Vimeo 
01 January 2013  
A newbie
portfolio
Zohar
Wellington,
New Zealand

Exactly. If you have three consecutive frames at time t0, t1, t2, with a uniform time step dt, and you want the velocity v1 (for time t1) at a mesh vertex with given point coordinates for each frame x0, x1, x2, then as you said before, each of the three options is legit:
1. v1 = (x2x1)/dt 2. v1 = (x1x0)/dt 3. v1 = (x2x0)/(2dt) where xixj is the distance (vector length, norm) between point xi and xj. 
01 January 2013  
Expert

Thread automatically closed
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities Note that as CGTalk Members, you agree to the terms and conditions of using this website. 
Thread Closed share thread 
«
Previous Thread

Next Thread
»


