View Full Version : Spline tangent and vectors...

 Mike Abbott08 August 2006, 08:03 PMStruggling to get to grips with this - I'm no programmer and haven't quite got my head around vectors and matrices yet... I've got a ThinkingParticles set up - based on the 'TP spline emitter' object in the library using a spline on the XZ plane. I can basically understand the 'TP sline emitter' set up - how the emitter is distributed over the spline length etc. However... What I want the emitter to do is to emit from the spline - but at right angles to the tangent of the spline at each individual location. That's where I'm having difficulty. I can see that the spline node has a tangent output port available - outputting vector data (is this a velocity vector?). So what I want to do is add "90 degrees" (or approx 1.57 radians) to that direction, without adjusting the emission speed. Can someone tell me how to change just that angle? Thanks, Mike A.
Srek
08 August 2006, 06:27 AM
There is no single right angle to a tangent. A tangent is just a vector in a 3D space and there are unlimited other vectors that have a 90° angle to it.
You will need an additional fixed point beside the vector to define a specific direction.
Cheers
Björn

Mike Abbott
08 August 2006, 08:03 AM
I thought you might say that ;)

So let me be more specific:
How would I do this on the basis that the spline lines flat on the XZ plane and my other point of reference is Y ("up")?

Mike

Srek
08 August 2006, 09:20 AM
The vector cross product is what you are looking for. Using it on the tangent and a second vector that points to +y (0,1,0 should be sufficent in global space) will give you a new vector that is at a right angle to the plane described by the two vectors.
Keep in mind that this is only a direction vector not a point vector.
Cheers
Björn

Mike Abbott
08 August 2006, 11:01 AM
The vector cross product...
will give you a new vector that is at a right angle to the plane described by the two vectors.
Keep in mind that this is only a direction vector not a point vector.

Thanks Björn,
OK - but could you educate me on the difference between a direction and point vector? and how I could create one if I have the other?

Mike

tcastudios
08 August 2006, 12:20 PM
Direction is like North South, up, down etc.
Pointvector is like a specific place on a map in relation to onother place.

Rotation would only have direction vectors.
Placing an object need a point vector, "place this object at xyz in relation to xyz.

Cheers
Lennart

Mike Abbott
08 August 2006, 01:30 PM
Thanks Lennart

I'm sorry to labour this guys, but I just want to make sure I'm on the right track...

As an example:

If, in Xpresso, I take a Global Matrix and wire it to a Matrix2Vectors node I get
Offset
V1
V2
V3
on the output side.

Am I right in thinking that Offset defines the common position (the 'tail' or 'origin') of all 3 vectors, and that V1,V2 & V3 define the location of the 'head' of each of the vectors along the X, Y & Z axis respectively?

So are V1,V2 & V3 direction vectors?

Mike

Srek
08 August 2006, 05:26 PM
Yes, V1 to V3 are the directions defining a local rectangular coordinate system. Usualy they are normals with the length one, except if you scaled the object axis. Offset or V0 is the position information.
Maybe check XPresso Anonymous for more http://www.bonkers.de/xpa/coordinates.html
Whenevery you need a local direction pointing along one of the objects axis you can use V1-V3 for this. This can be pretty handy for some setups.

Cheers
Björn

Mike Abbott
08 August 2006, 01:17 PM
Anyone care to take a look at the attachment - a simple set up showing emission at 90 degrees to the tangent of a spline.

It OK if I manipulate the points of the spline - or move or scale the spline as a whole,
but whatever I do I can't get it to work correctly when I rotate the spline as a whole (in the XZ plane only) - the emission retains it's original direction, or if I set up local coordinates in the spline node, the emission and spline part company...

Can anyone clue me in as to what's wrong?

On an associated note:

I may well be in the market to hire an Xpresso / TP expert for some ad-hoc work, training and hand-holding in the comming week. So if anyone is interested, please contact me.

Thanks,

Mike A.

Srek
08 August 2006, 01:40 PM
Hi,
you are mixing up global and localvectors and coordinates here.
Particles always use global coordinates, but to maintain your tangential emission you will need to calculate it in the local coordinates of the spline and then convert emission position and velocity to global space.
For this purpose you will find the presets "Global Point" and "Global Vector" in the Matrix XPool.
Use them to convert the position and velocity information, set the spline node to local coordinates and it should work as expected.

Hope this helps
Björn

Mike Abbott
08 August 2006, 01:55 PM
Hi,
you are mixing up global and localvectors and coordinates here....
Hope this helps

Björn,
Many, many thanks. I really appreciate your input on this.
I thought it was a global / local coordinates issue, but I had no idea why. I can now go away and study the example and manual some more :)

...and drop me a line if you're interested in some evening work ;)

Thanks again

CGTalk Moderation
08 August 2006, 01:55 PM
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.

1