WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   vertex list (https://forum.worldviz.com/showthread.php?t=2119)

jaclyn.bill 06-30-2009 03:54 AM

vertex list
 
Hi,

I'm trying to get vizard to draw a set of lines on a certain length along a ground plane which follow a curving path (essentially creating basic road markings).

I really want the lines to follow a set of vertex points set by

x = np.linspace(-np.pi, np.pi, length)
y = x, np.sin(x)
z = some constant

However, I can't seem to get these functions to work in vizard when I create an array:

Code:

roadarray = 0.0*np.zeros(201,3)

roadarray[0] = x
roadarray[1] = y
roadarray[2] = z
               

viz.startlayer(viz.LINE_STRIP)
viz.linewidth(4)
viz.vertexcolor(0, 0.6, 0)
viz.vertex(roadarray[0],roadarray[1],roadarray[2])
lines = viz.endlayer()

Vizard is having problems reading "roadarray = 0.0*np.zeros(201,3)" (saying "TypeError: data type not understood") even though I can get this to create an array in python.

I'm sure this is a small error on my part, but if any one can point me in the right direction I would be grateful.

Many thanks.

J

farshizzo 06-30-2009 09:27 AM

It looks like you are using the numpy.zeroes function incorrectly. I believe it should be:
Code:

roadarray = 0.0*np.zeros((201,3)) #Need the inner parentheses

jaclyn.bill 07-01-2009 07:17 AM

Hi,

I'm sorry but I'm still having problems with this and can't understand why it won't read my array. It is giving the error "TypeError: x must be a float" if I try to convert x to a float (which I thought it already was) I get the error "TypeError: only length-1 arrays can be converted to Python scalars
".

Code:


length = 200
viz.startlayer(viz.LINE_STRIP)
viz.vertexcolor(1,1,1)
viz.linewidth(5)
roadarray = 0.0*np.zeros((length,3))
x = np.linspace(-np.pi, np.pi, length)
z = np.sin(x)
roadarray[:length,0]= x
roadarray[:length,1]= 0
roadarray[:length,2]= z
viz.vertex(roadarray[:length,0],roadarray[:length,1],roadarray[:length,2])
lines = viz.endlayer()

I'd be grateful for any advice on this, I'm not a python expert!

Best, j


All times are GMT -7. The time now is 05:37 AM.

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