Closed nilsbecker closed 6 years ago
Do you have an image of what you are trying to achieve? gr3.createsurfacemesh
would used be for creating a surface plot. A "rectangular grid of lines" sounds more like something built from cylinders (and possibly spheres for the corners) like this:
import gr3
import numpy as np
n_per_axis = 11
n = 2*n_per_axis
positions = np.zeros((n, 3))
positions[:n_per_axis, 0] = np.linspace(-2, 2, n_per_axis)
positions[:n_per_axis, 1] = -2
positions[n_per_axis:, 0] = -2
positions[n_per_axis:, 1] = np.linspace(-2, 2, n_per_axis)
directions = np.zeros((22, 3))
directions[:n_per_axis, 1] = 1
directions[n_per_axis:, 0] = 1
colors = np.ones((22, 3))
radii = 0.01 * np.ones(22)
lengths = 4 * np.ones(22)
gr3.drawcylindermesh(n, positions, directions, colors, radii, lengths)
gr3.export("grid.png", 1000, 1000)
As an aside: 0 * gr3.GR3_SurfaceOption.GR3_SURFACE_FLAT
is equal to 0
and therefore gr3.GR3_SurfaceOption.GR3_SURFACE_DEFAULT
.
thanks! this looks like what i would like to achieve. i did not think of the cylinder option - i was considering that there must be some sort of 'line' primitive also in 3D with a constant width. the surface plot functions must also use something like that to draw the mesh, no? would a surface plot of a constant-zero function not also work?
the 0 * ..
bit was a quick test that i mistakenly copied-and-pasted.
GR3 does not support 2D primitives like points and lines, so cylinders or cuboids would be the way to go for a grid. The gr3_createsurfacemesh
function creates a 3D mesh based on the x, y and z arrays.
i think i misunderstood what gr3_createsurfacemesh
does. i thought it generates a wireframe-like surface representation. but instead it generates a surface mesh which is rendered as a solid surface -- correct?
Correct. Together with functions like gr3.surface
and gr3.drawsurface
it serves as somewhat of an equivalent to gr.surface
.
i would like to draw a rectangular grid of lines in the xy-plane with gr3. so far i could not make it work. i tried something like this:
and then
but this made the entire viewport white.
follow-up: how to draw a cuboid - line grid in 3d?