View Full Version : Scaling along a vector
03-26-2002, 03:22 AM
okay, everything else is solved http://www.opengl.org/discussion_boards/ubb/biggrin.gif. Now I'm facing the next problem which is scaling an object along a given vector http://www.opengl.org/discussion_boards/ubb/confused.gif. What I need is the mathematics behind it not the glFuncs.
03-26-2002, 06:55 AM
Scaling along a vector doesn't really make any sense. It seems like what you mean is scaling along a local coordinate system (which doesn't necessarily have to be the local coordinate system of the object, if there even is one).
Or are you trying to achieve an effect closer to something like Soft Selection+Translation which is common in Modeling Programs like 3d Studio Max or Maya.
is this what u want>
vertex.x = vertex.x + vector.x * scaling_factor
vertex.y = vertex.y + vector.y * scaling_factor
vertex.z = vertex.z + vector.z * scaling_factor
03-26-2002, 10:21 AM
I think mphanke is asking how to stretch an object in a given direction.
One method to do that would be to transform(rotate) your objects (using your code not gl's) such that one of the axes aligns with the direction in which the object has to be stretched.Then scale the objects along the axis with the scale factor and lastly do the inverse transformation to return to your original coordinate system.
Another method would be. . .(I havent checked this out yet, but seems to be right)
if V (vector)is your vertex,S (scalar) the scaling factor,D (unit vector) the direction in which scaling is to be done, then
V' = V + (S-1)*(Vp)
where Vp is the vector obtained by projecting V onto D.
hope this helps.
[This message has been edited by tarantula (edited 03-26-2002).]
03-26-2002, 11:05 AM
thanks very much to all of you! Tarantula got me right that was exactly what I was looking for. As a short explanation, what I'm doing is fitting 4 point clouds together to recreate a physical object.
If someone is intrested mail me I have some funcs done (things like rotating around a given vector, a point in space and a vector, all rotations and all transformations http://www.opengl.org/discussion_boards/ubb/wink.gif, all physical vertex transforms!)
That would then be my way to say thanks to all of you!
Again thanks very much,
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.