/usr/share/dx/samples/scripts/Compute is in dxsamples 4.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | macro main() {
// Import the data
electrondensity = Import("watermolecule");
// Partition the data
//electrondensity = Partition(electrondensity);
// Compute the field squared
esquared = Compute("$0^2",electrondensity);
// Take the gradient of the original field
gradient = Gradient(electrondensity);
// Extract only the x component of the gradient field
xcomponent = Compute("$0.x",gradient);
// Create two isosurfaces, don't create normals for shading
iso1 = Isosurface(electrondensity,0.3,flag=0);
iso2 = Isosurface(electrondensity,0.35,flag=0);
// Create a camera
camera = AutoCamera(iso1);
// Create two images and display them
image1 = Render(iso1,camera);
Display(image1);
image2 = Render(iso2,camera);
Display(image2);
// Mark the "colors" component in each images as the "data" component
// so that Compute can operate on them
image1 = Mark(image1,"colors");
image2 = Mark(image2,"colors");
// Compute the difference between the two images
difference = Compute("$0 - $1",image1,image2);
image = Unmark(difference,"colors");
// Display the result
Display(image);
// Create a 2D slice of the data, through the center
slice = Slice(electrondensity, "z", 5);
// Color the slice
slice = AutoColor(slice);
// Display the slice
camera = AutoCamera(slice);
caption = Caption("Original Slice");
collected = Collect(caption, slice);
Display(collected,camera);
// Mark the positions so that they can be computed on
// The original x positions go from -1 to 2.9
// The original y positions go from -3 to 2.9
markedslice = Mark(slice,"positions");
// Warp the positions onto the shape of a cylinder
pi = 3.14159;
function = "[sin(2*$1*($0.x+1)/3.9), $0.y,-cos(2*$1*($0.x+1)/3.9)]";
warped = Compute(function, markedslice, pi);
// Unmark the warped positions, returning them to the positions
// component
warped = Unmark(warped, "positions");
// Add shading
warped = Normals(warped);
camera = AutoCamera(warped,"off-diagonal");
caption = Caption("Warped into the shape of a cylinder");
collected = Collect(caption,warped);
Display(collected, camera);
// Now warp the positions onto the shape of a doubled cone
// by multiplying the x and z positions by the original
// y value, which goes from -3 to 2.9
fnctn="[$0.y*sin(2*$1*($0.x+1)/3.9),$0.y,-$0.y*cos(2*$1*($0.x+1)/3.9)]";
warped = Compute(fnctn, markedslice, pi);
// Unmark the warped positions, returning them to the positions
// component
warped = Unmark(warped, "positions");
// Add shading
warped = Normals(warped);
caption = Caption("Warped into the shape of a double cone");
collected = Collect(caption,warped);
Display(collected, camera);
// For illustration, Construct a 2D grid which represents longitude (x
// positions) and latitude (y positions).
grid = Construct([0, -90], [5 5], [73, 37], {-1350 .. 1350});
grid = Compute("abs($0)",grid);
// convert the positions of the grid from degrees to radians for convenience
grid = Mark(grid,"positions");
markedgrid = Compute("($0*$1)/180.0", pi, grid);
grid = Unmark(markedgrid,"positions");
colored = AutoColor(grid);
camera = AutoCamera(grid);
colored = AutoAxes(colored,camera);
caption = Caption("Original latitude and longitude grid (radians)");
collected = Collect(caption,colored);
Display(collected, camera);
// Now warp the grid into the shape of a sphere.
fnctn="[cos($0.x)*cos($0.y), sin($0.y), sin($0.x)*cos($0.y)]";
warped = Compute(fnctn, markedgrid, pi);
// Unmark the warped positions, returning them to the positions
// component
warped = Unmark(warped, "positions");
// Add shading and colors
colored = AutoColor(warped);
colored = Normals(colored);
caption = Caption("Warped into the shape of a sphere");
collected = Collect(caption,colored);
camera = AutoCamera(colored,"off-diagonal");
Display(collected, camera);
}
main();
|