WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Draw line and rotate it (https://forum.worldviz.com/showthread.php?t=2230)

Chrissy2009 08-25-2009 03:22 PM

Draw line and rotate it
 
1 Attachment(s)
Hi,
I try to re-define my problem from the other thread:

I want to draw a line two ways:

1)
Code:

begin = [0,0,0]
end = [-2,1,2]

viz.startlayer(viz.LINES)
viz.linewidth(2)
viz.vertexcolor(viz.RED)
viz.vertex(begin)
viz.vertex(end)
viz.startlayer(viz.POINTS)
viz.pointsize(3)
viz.vertex(begin)               
viz.vertex(end)
dr = viz.endlayer()

and like this
2)
Code:

begin = [0,0,0]
end = [-2,1,2]

d = vizmat.Distance(begin,end)

viz.startlayer(viz.LINES)
viz.linewidth(2)
viz.vertexcolor(0,0,0.6)
viz.vertex(0,0,0)
viz.vertex(0,d,0)
viz.startlayer(viz.POINTS)
viz.pointsize(3)
viz.vertex(0,0,0)
viz.vertex(0,d,0)
drr = viz.endlayer()
drr.setPosition(begin)
drr.setEuler(0,0,-vizmat.AngleToPoint([begin[0],begin[1]],[end[0],end[1]]))


The rotation about the z-axis works very fine. (see scrennshot1)

But now I want to rotate the second line (the blue one) around the y-axis, too. So that I can see in the Top-View that the lines are exactly at the same place, the same direction, the same length and so on.

I've tested many ways, but I can't find a solution.

I've done:
Code:

drr.setEuler(-vizmat.AngleToPoint([begin[0],begin[2]],[end[0],end[2]]), 0, -vizmat.AngleToPoint([begin[0],begin[1]],[end[0],end[1]]))
and
Code:

drr.setEuler(vizmat.AngleToPoint([begin[0],begin[2]],[end[0],end[2]]), 0, -vizmat.AngleToPoint([begin[0],begin[1]],[end[0],end[1]]))
and
Code:

drr.setEuler(-vizmat.AngleToPoint([begin[2],begin[0]],[end[2],end[0]]), 0, -vizmat.AngleToPoint([begin[0],begin[1]],[end[0],end[1]]))
and
Code:

drr.setEuler(vizmat.AngleToPoint([begin[2],begin[0]],[end[2],end[0]]), 0, -vizmat.AngleToPoint([begin[0],begin[1]],[end[0],end[1]]))
but nothing works fine. Where is my mistake??

Thanks a lot....

farshizzo 08-28-2009 03:38 PM

In your second example, you are creating a line along the local Y-axis. So rotating that line around it's local Y-axis won't really do anything. Are you trying to draw 2D or 3D lines?

Chrissy2009 09-01-2009 08:26 AM

The lines should be drawn in 3D.

= = =

I want to draw three lines:

If I click with the left mousebutton, the first line would be drawn from P(0/0) to the acutal mouseposition and if I click again then the second one would be drawn, too. The z-value from the both lines is 0.

And now if I click a special button, I want to create a third line from the end of the first line to the end of the second line. This works fine if the z-values are 0.

BUT:

I'm possible to turn the two lines around the y-axis with the center at P(0/0).
So the z-values aren't 0.

And afterthat I want to create the third line and then it's wrong!

Chrissy2009 09-04-2009 12:02 AM

Hey,
is there really no possibility to solve my problem?

Isn't it possible to readout the angle of the first line and the z-axis and afterthat to rotate the line with the arrow about this value around the y-axis?

:confused::confused::confused:

lilio 09-04-2009 05:54 AM

Hey,
I've got another idea, to solve my problem. But therefore I should know, how to get the euler of my line.

So I draw a line like this:

Code:

begin = [0,0,0]
end = [2,1,2]

viz.startlayer(viz.LINES)
viz.linewidth(2)
viz.vertexcolor(viz.RED)
viz.vertex(begin)
viz.vertex(end)
viz.startlayer(viz.POINTS)
viz.pointsize(3)
viz.vertex(begin)               
viz.vertex(end)
dr = viz.endlayer()

And now I want to get the euler of this line.

But If I make

Code:

print dr.getEuler()
it is always [0, 0, 0].


Is it possible to get the euler of a drawn line?

Or the angles between the axes and my line.

Thanks a lot for all your help!

lilio 09-07-2009 01:10 AM

How can I get the euler of my line???


All times are GMT -7. The time now is 03:47 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC