Describe the bug
There seems to be a problem between parametric variables and rotate function. Using such variable in a shape constructor and then feeding the resulting shape to rotate function triggers an error.
Curv Program
Working:
let
a = 30;
in
rect (a, 2*a) >> rotate (45*deg)
Non-working:
parametric
a::slider[10,200] = 30;
in
rect (a, 2*a) >> rotate (45*deg)
Outputs:
939|> arg >> match [
940|> a :: is_num ->
941|> let // 2D rotation around the Z axis
942|> rot2(a,p) = cmul(p, cis a);
943|> b = if (shape.bbox[MIN,X] == -inf || shape.bbox[MIN,Y] == -inf
944|> || shape.bbox[MAX,X] == inf || shape.bbox[MAX,Y] == inf)
945|> [[-inf,-inf], [inf,inf]]
946|> else
947|> let bv = map (p->rot2(a,p)) [
948|> [shape.bbox[MIN,X], shape.bbox[MIN,Y]],
949|> [shape.bbox[MAX,X], shape.bbox[MIN,Y]],
950|> [shape.bbox[MAX,X], shape.bbox[MAX,Y]],
951|> [shape.bbox[MIN,X], shape.bbox[MAX,Y]],
952|> ];
953|> in [min bv, max bv];
954|> in make_shape {
955|> dist[x,y,z,t] :
956|> let xy = rot2(-a,[x,y]);
957|> in shape.dist(xy[X],xy[Y],z,t),
958|> colour[x,y,z,t] :
959|> let xy = rot2(-a,[x,y]);
960|> in shape.colour(xy[X],xy[Y],z,t),
961|> bbox : [
962|> [ b[MIN,X], b[MIN,Y], shape.bbox[MIN,Z] ],
963|> [ b[MAX,X], b[MAX,Y], shape.bbox[MAX,Z] ],
964|> ],
965|> is_2d : shape.is_2d,
966|> is_3d : shape.is_3d,
967|> };
968|> {angle, axis: a} ->
969|> do
970|> assert(shape.is_3d);
971|> in let
972|> axis = normalize a;
973|> rot3(a,axis,p) =
974|> p * cos(a)
975|> - cross(axis, p) * sin(a)
976|> + axis * dot(axis, p * (1 - cos a));
977|> b = if (shape.bbox[MIN,X] == -inf || shape.bbox[MIN,Y] == -inf
978|> || shape.bbox[MIN,Z] == -inf
979|> || shape.bbox[MAX,X] == inf || shape.bbox[MAX,Y] == inf
980|> || shape.bbox[MAX,Z] == inf
981|> )
982|> shape.bbox
983|> else
984|> let bb = shape.bbox;
985|> bv = map (p->rot3(-angle,axis,p)) [
986|> [bb[MIN,X], bb[MIN,Y], bb[MIN,Z]],
987|> [bb[MAX,X], bb[MIN,Y], bb[MIN,Z]],
988|> [bb[MAX,X], bb[MAX,Y], bb[MIN,Z]],
989|> [bb[MIN,X], bb[MAX,Y], bb[MIN,Z]],
990|> [bb[MIN,X], bb[MIN,Y], bb[MAX,Z]],
991|> [bb[MAX,X], bb[MIN,Y], bb[MAX,Z]],
992|> [bb[MAX,X], bb[MAX,Y], bb[MAX,Z]],
993|> [bb[MIN,X], bb[MAX,Y], bb[MAX,Z]],
994|> ];
995|> in [ min bv, max bv ];
996|> in make_shape {
997|> //TODO: dist p : shape.dist(...rot3(angle,axis,p[[X,Y,Z]]),p[T]),
998|> dist[x,y,z,t] :
999|> let q = rot3(angle, axis, [x,y,z]);
1000|> in shape.dist(q[X],q[Y],q[Z],t),
1001|> colour[x,y,z,t] :
1002|> let q = rot3(angle, axis, [x,y,z]);
1003|> in shape.colour(q[X],q[Y],q[Z],t),
1004|> bbox : b,
1005|> is_3d : true,
1006|> };
1007| ];
Expected behavior
Simple rectangle on output window.
System Information (please complete the following information):
Operating System: Ubuntu 18.04.
CPU manufacturer, model, version, and # of cores: Intel i7 4 cores, 8 threads
Amount of system memory: 16G
GPU manufacturer, model and version: AMD Radeon HD 7730M
GPU driver, if on Linux: Mesa over amdgpu opensource driver.
Are you running the curv command using a remote viewing protocol like VNC or NX? No
Are you running the curv command inside a VM? No
Curv Version: run the command curv --version and paste the output here.
Curv: 0.4-711-ge400c2ea-dirty
Compiler: gcc 9.3.0
Kernel: Linux 5.3.0-59-generic x86_64
GPU: X.Org, AMD Radeon HD 7700M Series (VERDE, DRM 3.33.0, 5.3.0-59-generic, LLVM 9.0.1)
OpenGL: 4.6 (Compatibility Profile) Mesa 20.0.4
Additional context
Using Snap package, master branch.
Describe the bug There seems to be a problem between parametric variables and
rotate
function. Using such variable in a shape constructor and then feeding the resulting shape to rotate function triggers an error.Curv Program Working:
Non-working:
Outputs:
Expected behavior Simple rectangle on output window.
System Information (please complete the following information):
curv
command using a remote viewing protocol like VNC or NX? Nocurv
command inside a VM? Nocurv --version
and paste the output here.Additional context Using Snap package, master branch.