scale_factor
has different meanings for different cameras. For the Arcball and Turntable they say scale_factor represents the zoom level so I would assume that anything less than 1 is just "closer" to the center point. I feel like I've seen one of these cameras used to look past the center point before, but not sure if that involved a negative scale factor or not. I'm sure I don't understand what's going on here as much as I should to properly participate in this discussion. I'd say if you feel strongly about this then maybe make a PR or at least an issue. It'll be easier to pull others into the discussion
glsl_imap = """
vec4 polar_transform_map(vec4 pos) {
float theta = atan(pos.y, pos.x);
theta = degrees(theta) + 180;
float r = length(pos.xy);
return vec4(theta, r, pos.z, 1);
}
"""
theta
in degrees between (0, 360). The r
value is evaluated correct so far I can tell from my output.
image_size
to normalize it to 360deg but this seems not accessible from the glsl_map function. Any ideas? Otherwise we could advertise this workaround, but a real solution would be better.
import numpy as np
import vispy.app
from vispy import gloo
from vispy import visuals
from vispy.visuals.transforms import (MatrixTransform, STTransform,
PolarTransform)
class MyPolarTransform(PolarTransform):
glsl_map = """
vec4 polar_transform_map(vec4 pos) {
return vec4(pos.y * cos(pos.x), pos.y * sin(pos.x), pos.z, 1.);
}
"""
glsl_imap = """
vec4 polar_transform_map(vec4 pos) {
float theta = atan(pos.y, pos.x);
//theta = theta + 3.14159265358979323846;// + 180;
theta = degrees(theta) + 180;
float r = length(pos.xy);
return vec4(theta, r, pos.z, 1);
}
"""
class Canvas(vispy.app.Canvas):
def __init__(self):
csize = 360 * 3
vispy.app.Canvas.__init__(self, keys='interactive', size=(csize, csize))
# Create image
image = np.ones((360, 360, 3), dtype=np.uint8)
grad = np.linspace(0, 255, 360, dtype=np.uint8)[None, :, None]
image *= grad
image[:, 310:360, :] = 0
image[5:40] = 255
image[:, 10:50, :] = 255
#image = np.swapaxes(image, 0, 1)
image2 = image
self.images = [visuals.ImageVisual(image, method='impostor') for i in range(4)]
self.images2 = [visuals.ImageVisual(image2, method='impostor') for i in range(4)]
for i, im in enumerate(self.images):
tx = 0
ty = 0
if i == 1:
tx = self.images[0].size[1]
xoff = csize / 4 * 3
yoff = csize / 4
elif i == 2:
tx = self.images[0].size[0]
ty = self.images[0].size[1]
xoff = csize / 4
yoff = csize / 4 * 3
elif i == 3:
ty = self.images[0].size[0]
xoff = csize / 4 * 3
yoff = csize / 4 * 3
else:
xoff = csize / 4
yoff = csize / 4
r0 = MatrixTransform()
off = i * 90
r0.rotate(off, (0, 0, 1))
roti = (
STTransform(translate=(tx, ty, 0)) *
r0
)
tr1 = (STTransform(scale=(0.5, 0.5, 1), translate=(xoff, yoff, 0)) *
#r0 *
MyPolarTransform() *
roti
)
tr2 = (STTransform(scale=(1.0, 1.0, 1), translate=(xoff-csize/4, yoff-csize/4, 0)) #*
)
self.images[i].transform = tr1
self.images2[i].transform = tr2
self.visuals = [*self.images, *self.images2]
self.show()
def on_draw(self, ev):
gloo.clear(color='w', depth=True)
for vis in self.visuals:
vis.draw()
def on_resize(self, event):
# Set canvas viewport and reconfigure visual transforms to match.
vp = (0, 0, self.physical_size[0], self.physical_size[1])
self.context.set_viewport(*vp)
for vis in self.visuals:
vis.transforms.configure(canvas=self, viewport=vp)
if __name__ == '__main__':
win = Canvas()
import sys
if sys.flags.interactive != 1:
vispy.app.run()
Volumes
: is there a straight forward way to scale them? For example, I would like each voxel to have a isometric (or perhaps even non-isometric) size for easier co-visualization with other data. Perhaps with some kind of transform?