|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I have a question for a problem relating to 3D rotations.
I'm working on a bspline plug-in dll for Moray. Its very close to being
ready for release once I get this small problem fixed.
So here it is:
I'm creating a tube like object for the spline by using a series of 'discs'
along the path of the spline and orientating its surface or normal to point
to the next joint or point along the spline. Using the following math and
trig functions that Sean Worle provided:
rz = atan2(dx, dy);
rx = atan2(sqrt(dx*dx + dy*dy), dz);
atan2 = arctangent of y/x (in radians)
where dx, dy, dz are the differences between the current point and the next
point in the spline.
rz and rx are the amount to rotate the disc in the z and x axis. The disc
is created in the X-Y plane.
The problem is when I create a b-spline object along the Z axis, which looks
like a straigt cylinder (or tube) - it is fine. But if one of the points
moves in the x direction, then the disc is rotated by 90 degrees along the Z
axis which is not good. But it does this because when using atan2 and the
dx goes negative it returns -90.
I certainly would appreciate any help. I can provide pictures if needed.
--
Mike
wk: mik### [at] pyxiscom www.pyxis.com
hm: mwe### [at] sciticom www.geocities.com/mikepweber
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
sorry, no math help here, but why are you using disks? wouldn't spheres work?
rotation wouldn't matter then would it?
Mike Weber wrote:
> I have a question for a problem relating to 3D rotations.
> I'm working on a bspline plug-in dll for Moray. Its very close to being
> ready for release once I get this small problem fixed.
>
> So here it is:
>
> I'm creating a tube like object for the spline by using a series of 'discs'
> along the path of the spline and orientating its surface or normal to point
> to the next joint or point along the spline. Using the following math and
> trig functions that Sean Worle provided:
>
> rz = atan2(dx, dy);
> rx = atan2(sqrt(dx*dx + dy*dy), dz);
>
> atan2 = arctangent of y/x (in radians)
>
> where dx, dy, dz are the differences between the current point and the next
> point in the spline.
> rz and rx are the amount to rotate the disc in the z and x axis. The disc
> is created in the X-Y plane.
>
> The problem is when I create a b-spline object along the Z axis, which looks
> like a straigt cylinder (or tube) - it is fine. But if one of the points
> moves in the x direction, then the disc is rotated by 90 degrees along the Z
> axis which is not good. But it does this because when using atan2 and the
> dx goes negative it returns -90.
>
> I certainly would appreciate any help. I can provide pictures if needed.
>
> --
> Mike
>
> wk: mik### [at] pyxiscom www.pyxis.com
> hm: mwe### [at] sciticom www.geocities.com/mikepweber
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I'm really using triangles, but to get the point across I use disc.
Triangles will be used to create the tube where one triangle's vertex will
be at a point on the circumference of the disc, and the two other vertices
of the triangle will be at two points on the circumference of the next disc
locate at the next point along the spline.
--
Mike
wk: mik### [at] pyxiscom www.pyxis.com
hm: mwe### [at] sciticom www.geocities.com/mikepweber
"ryan constantine" <rco### [at] yahoocom> wrote in message
news:38E13E2A.A5EF47B0@yahoo.com...
> sorry, no math help here, but why are you using disks? wouldn't spheres
work?
> rotation wouldn't matter then would it?
>
> Mike Weber wrote:
>
> > I have a question for a problem relating to 3D rotations.
> > I'm working on a bspline plug-in dll for Moray. Its very close to being
> > ready for release once I get this small problem fixed.
> >
> > So here it is:
> >
> > I'm creating a tube like object for the spline by using a series of
'discs'
> > along the path of the spline and orientating its surface or normal to
point
> > to the next joint or point along the spline. Using the following math
and
> > trig functions that Sean Worle provided:
> >
> > rz = atan2(dx, dy);
> > rx = atan2(sqrt(dx*dx + dy*dy), dz);
> >
> > atan2 = arctangent of y/x (in radians)
> >
> > where dx, dy, dz are the differences between the current point and the
next
> > point in the spline.
> > rz and rx are the amount to rotate the disc in the z and x axis. The
disc
> > is created in the X-Y plane.
> >
> > The problem is when I create a b-spline object along the Z axis, which
looks
> > like a straigt cylinder (or tube) - it is fine. But if one of the
points
> > moves in the x direction, then the disc is rotated by 90 degrees along
the Z
> > axis which is not good. But it does this because when using atan2 and
the
> > dx goes negative it returns -90.
> >
> > I certainly would appreciate any help. I can provide pictures if
needed.
> >
> > --
> > Mike
> >
> > wk: mik### [at] pyxiscom www.pyxis.com
> > hm: mwe### [at] sciticom www.geocities.com/mikepweber
>
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Your plugin is interesting! Send me more information, I will have
a look to this :).
Fabian.
>
> I have a question for a problem relating to 3D rotations.
> I'm working on a bspline plug-in dll for Moray. Its very close to being
> ready for release once I get this small problem fixed.
>
> So here it is:
>
> I'm creating a tube like object for the spline by using a series of 'discs'
> along the path of the spline and orientating its surface or normal to point
> to the next joint or point along the spline. Using the following math and
> trig functions that Sean Worle provided:
>
> rz = atan2(dx, dy);
> rx = atan2(sqrt(dx*dx + dy*dy), dz);
>
> atan2 = arctangent of y/x (in radians)
>
> where dx, dy, dz are the differences between the current point and the next
> point in the spline.
> rz and rx are the amount to rotate the disc in the z and x axis. The disc
> is created in the X-Y plane.
>
> The problem is when I create a b-spline object along the Z axis, which looks
> like a straigt cylinder (or tube) - it is fine. But if one of the points
> moves in the x direction, then the disc is rotated by 90 degrees along the Z
> axis which is not good. But it does this because when using atan2 and the
> dx goes negative it returns -90.
>
> I certainly would appreciate any help. I can provide pictures if needed.
>
> --
> Mike
>
> wk: mik### [at] pyxiscom www.pyxis.com
> hm: mwe### [at] sciticom www.geocities.com/mikepweber
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Love to help, thinking about it now... I am half figuring it out, seeing
pictures would be good, emailing them directly to me fine. Be
warned I'm not a programmer by nature, but a mathematics person,
so don't be surprised if I have no idea what a bspline is.
I think you don't want rotation in the z direction, as if the disk is created in
X-Y, then rotating it about Z, just rotates the circle, which is a symmetrical
object. You want some y rotation instead. If this isn't right I'll need some
more info.
I'm, thinking about it at the moment, I don't think the above would cause
that kind of a problem.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hello Mike
If I have understood your problem right, then I have had
similar problems myself.
I have tried to modify two of my POV-macros so that they
suit your problem.
See the code below for my solution.
If this is not what you need, then I will need more
information to solve your problem.
Tor Olav
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html
Mike Weber wrote:
> I have a question for a problem relating to 3D rotations.
> I'm working on a bspline plug-in dll for Moray. Its very close to being
> ready for release once I get this small problem fixed.
Because I don't master the C-language, my code is POV-ray syntax,
which is not very suited for a dll.
> So here it is:
>
> I'm creating a tube like object for the spline by using a series of 'discs'
> along the path of the spline and orientating its surface or normal to point
> to the next joint or point along the spline. Using the following math and
> trig functions that Sean Worle provided:
>
> rz = atan2(dx, dy);
> rx = atan2(sqrt(dx*dx + dy*dy), dz);
>
> atan2 = arctangent of y/x (in radians)
I think you need to keep track of which quadrant you are in before you
apply the rotations. As far as I can see it, you loose that information
when you apply the formulas above.
> where dx, dy, dz are the differences between the current point and the next
> point in the spline.
> rz and rx are the amount to rotate the disc in the z and x axis. The disc
> is created in the X-Y plane.
Are you sure that it is wise to create your objects in the X-Y plane?
The torus object in POV-ray is always created in the X-Z plane.
And this may create problems for you if you want to "string up" toruses
instead of discs.
My original macros were made for tilting objects "created" in the X-Z
plane. (If you look in my recent posting to povray.text.scene-files
"Bumpy CSG-sphere" you will find these macros under the names:
vtilt & VectorAngles)
> The problem is when I create a b-spline object along the Z axis, which looks
> like a straigt cylinder (or tube) - it is fine. But if one of the points
> moves in the x direction, then the disc is rotated by 90 degrees along the Z
> axis which is not good. But it does this because when using atan2 and the
> dx goes negative it returns -90.
Wouldn't you have to accumulate up the rotations that is needed when
wandering from point to point in your spline?
> I certainly would appreciate any help. I can provide pictures if needed.
#macro VA(Vector)
// Vector Angles
<acos(vnormalize((x+y)*Vector).x)*(Vector.y > 0 ? -1 : 1),
acos(vnormalize(Vector).z),
0>
#end // macro VA
#macro VT(Thing, TVector)
// Vector Tilt
#local RotateAngles = VA(TVector);
object {
Thing
rotate degrees(RotateAngles.x)*z
rotate degrees(RotateAngles.y)*y
rotate -degrees(RotateAngles.x)*z
}
#end // macro VT
#declare dx = 0.2;
#declare dy = -0.3;
#declare dz = 0.5;
#declare TiltDirection = <dx, dy, dz>;
#declare OneBox = box { <6, 3, -1>/6, <-6, -3, 1>/6 }
#declare TiltedBox = VT(OneBox, TiltDirection)
object {
TiltedBox
pigment { color Red }
}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Tor,
Thanks for your input.
You POV code is similar to what I am doing. You are rotating only on the X
and Y axis and not the Z where I rotate only on the X and Z axis and not the
Y. I'm not familiar with the POV normalize instruction, but maybe I could
learn something from that.
Mike
Tor Olav Kristensen <tto### [at] onlineno> wrote in message
news:38E8C44E.81C7E687@online.no...
> Hello Mike
>
> If I have understood your problem right, then I have had
> similar problems myself.
>
> I have tried to modify two of my POV-macros so that they
> suit your problem.
>
> See the code below for my solution.
>
> If this is not what you need, then I will need more
> information to solve your problem.
>
> Tor Olav
>
> Wouldn't you have to accumulate up the rotations that is needed when
> wandering from point to point in your spline?
>
Not sure what you mean by that??
Mike
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mike Weber wrote:
> Tor,
>
> Thanks for your input.
> You POV code is similar to what I am doing. You are rotating only on the X
> and Y axis and not the Z where I rotate only on the X and Z axis and not the
> Y. I'm not familiar with the POV normalize instruction, but maybe I could
> learn something from that.
vnormalize multiplies the vector with a scalar
so that the length of the vector becomes equal
to 1.
This is done by choosing a scalar that is equal
to the reciprocal of the vectors current length.
I.e. if it is a 3D-vector:
1/sqrt(pow(Vector.x, 2) +
pow(Vector.y, 2) +
pow(Vector.z, 2))
Note that if Vector is a null-vector (e.g. <0, 0>
or <0, 0, 0>) then (in POV-Ray) vnormalize(Vector)
just leaves it as a null-vector.
While this expression would generate a warning
message if Vector is a null-vector (division
by zero):
1/(vlength(Vector))*Vector
If 3D-vectors were used, then my expression;
<acos(vnormalize((x + y)*Vector).x)*(Vector.y > 0 ? -1 : 1),
acos(vnormalize(Vector).z),
0>
could be written like this:
#if(Vector.y > 0)
#local Sign = 1;
#else
#local Sign = -1;
#end // if
<-Sign*acos(Vector.x/sqrt(pow(Vector.x, 2) +
pow(Vector.y, 2))),
acos(Vector.z/sqrt(pow(Vector.x, 2) +
pow(Vector.y, 2) +
pow(Vector.z, 2))),
0>
The last part could also be written like this
<-Sign*acos(Vector.x/vlength((x+y)*Vector)),
acos(Vector.z/vlength(Vector)),
0>
But with these two expressions one would have to
check if the x and y components were both zero.
> Tor Olav Kristensen <tto### [at] onlineno> wrote in message
> news:38E8C44E.81C7E687@online.no...
> ...
> > Wouldn't you have to accumulate up the rotations that is needed when
> > wandering from point to point in your spline?
> >
> Not sure what you mean by that??
>
> Mike
When using rotate in POV-Ray, the rotations is
always done around origo.
If you calculated this rotation relative to the
previous point (as is my understanding of your
description) and then applied the rotation relative
to origo, believe it would end up with a wrong
rotation relative to the previous point.
But if you take a copy of the object as it is
when it's rotated to the "last point" and then
applies the new rotations to make it point to
the "next point" then (I guess) it will become
right.
And my idea was that instead of making a copy of
the object as it was after it had last been copied,
you could just add together all the rotations that
had been done until the "last point" and then add
the new rotations to these rotations before
applying them to a copy of the object as it was
when created in your XZ-plane.
But again I don't know if my assumptions about
what you are really doing, is right. :)
...And maybe all my "believes" and theories
don't hold...
Tor Olav
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Tor Olav Kristensen" <tto### [at] onlineno> wrote in message
news:38EA1167.DC358C7B@online.no...
>
>
> > Tor Olav Kristensen <tto### [at] onlineno> wrote in message
> > news:38E8C44E.81C7E687@online.no...
> > ...
> > > Wouldn't you have to accumulate up the rotations that is needed when
> > > wandering from point to point in your spline?
> > >
> > Not sure what you mean by that??
> >
> > Mike
>
> When using rotate in POV-Ray, the rotations is
> always done around origo.
>
> If you calculated this rotation relative to the
> previous point (as is my understanding of your
> description) and then applied the rotation relative
> to origo, believe it would end up with a wrong
> rotation relative to the previous point.
>
> But if you take a copy of the object as it is
> when it's rotated to the "last point" and then
> applies the new rotations to make it point to
> the "next point" then (I guess) it will become
> right.
>
> And my idea was that instead of making a copy of
> the object as it was after it had last been copied,
> you could just add together all the rotations that
> had been done until the "last point" and then add
> the new rotations to these rotations before
> applying them to a copy of the object as it was
> when created in your XZ-plane.
>
> But again I don't know if my assumptions about
> what you are really doing, is right. :)
>
> ...And maybe all my "believes" and theories
> don't hold...
>
No, you are correct. Your ideas are very similar. However, my object is
rotated at the origin (origo), then translated to the appropriate position.
The rotation is based on the angle between the the previous point and the
current point.
Mike
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|