### Table of Contents

## Let's try to shift, scale, rotate objects

### Let's try to shift objects

Array x in my_model(x[3], a[1]) includes coordinates in three dimensions. The corresponding relationship is,

x[1] -> x x[2] -> y x[3] -> z

The following is an equation of a solid sphere which has its center as the origin and a radius of 5: The model in HyperFun:

my_model(x[3], a[1]) { sphere = 5.0^2 - (x[1]^2 + x[2]^2 + x[3]^2); my_model = sphere; }

What is the difference between these two equations: and ? We will experiment with two equations in HyperFun.

my_model(x[3], a[1]) { sphere = 5.0^2 - ((x[1]-5.0)^2 + x[2]^2 + x[3]^2); my_model = sphere; }

Then what is the difference between these two equations: and ? We will experiment with two equations in HyperFun.

my_model(x[3], a[1]) { sphere = 5.0^2 - ((x[1]+5.0)^2 + x[2]^2 + x[3]^2); my_model = sphere; }

The result of experiments with HyperFun shows us that replacing x with x*-5* is equal to moving only 5 in the positive direction of the x-axis, and replacing x with x*+5* is equal to moving only 5 in the negative direction of the x-axis.

Question:

Given the equation , how is this equation moved only 5 in the positive direction of the x-axis?

Answer:

Let's try to shift the sphere in the direction of the y-axis, the z-axis. In HyperFun, there is only one operation for shifting in 3D space: hfShift3D

### Let's try to scale objects

First let's make a sphere, which has its center as the origin and a radius of 5.

my_model(x[3], a[1]) { sphere = 5.0^2 - (x[1]^2 + x[2]^2 + x[3]^2); my_model = sphere; }

What is the dirference between these two equations: and ? We will experiment in HyperFun, replacing x[1] with x[1]/2.

my_model(x[3], a[1]) { sphere = 5.0^2 - ((x[1]/2)^2 + x[2]^2 + x[3]^2); my_model = sphere; }

What is the dirference between these two equations: and ? We will experiment in HyperFun, replacing x[1] with x[1]*2.

my_model(x[3], a[1]) { sphere = 5.0^2 - ((x[1]*2)^2 + x[2]^2 + x[3]^2); my_model = sphere; }

As the result of experimenting with HyperFun, a sphere is scaled twice with the x-axis, replacing x with x/2, a sphere is scaled 1/2 times with the x-axis, replacing x with x*2. Let's try to scale the sphere with y-axis, z-axis in the same way.

In HyperFun, there is only one operation for scaling: hfScale3D

### Let's try to rotate objects

Rotating at s radian in three dimension around the z-axis is described in HyperFun as follows, (s radian is *pi*s/180* degree.)

x' = x cos(s) + y sin(s) y' = y cos(s) - x sin(s) z' = z

We will experiment with the upper expressions in HyperFun.

my_model(x[3], a[1]) { array xt[3]; pi = 3.14159; deg2rad = pi/180.0; sphere1 = 3.0^2 - ((x[1] - 5)^2 + x[2]^2 + x[3]^2); xt[1] = x[1]*cos(deg2rad*90.0) + x[2]*sin(deg2rad*90.0); xt[2] = x[2]*cos(deg2rad*90.0) - x[1]*sin(deg2rad*90.0); xt[3] = x[3]; sphere2 = 3.0^2 - ((xt[1] - 5)^2 + xt[2]^2 + xt[3]^2); my_model = sphere1 | sphere2; }

The sphere1 is a sphere which has the center of (5, 0, 0) and a radius of 3. The sphere2 is the sphere1 which is rotated at a 90 angle around the z-axis. As the result of using the upper expressions, we can make a sphere rotate at a 90 angle around the z-axis. The following expressions are ones of rotation around y-axis and z-axis.

Let's try to use them.

Expressions of rotation around y-axis.

x' = x cos(s) - z sin(s) y' = y z' = x cos(s) + z sin(s)

Expressions of rotation around x-axis.

x' = x y' = y cos(s) + z sin(s) z' = z cos(s) - y sin(s)

In HyperFun, there are three operations for rotation: hfRotate3DZ (rotation around z-axis), hfRotate3DY (rotation around y-axis), hfRotate3DX (rotation around x-axis).