private void OnMouseMove(object sender, MouseEventArgs e) { if (isMouseDown) { float2 offset = new float2((e.X - mouseLocation.x) * mouseSensitivity, (e.Y - mouseLocation.y) * mouseSensitivity); float c1 = DeviceFunction.Cos(offset.x); float s1 = DeviceFunction.Sin(offset.x); float t1 = 1 - c1; float c2 = DeviceFunction.Cos(offset.y); float s2 = DeviceFunction.Sin(offset.y); float t2 = 1 - c2; float camDist = L(camera); gpu.Launch(RotateDirection, launchParam, dirDevPtr, y, t1, c1, s1, width, height); x = RotateVec(x, y, t1, c1, s1); z = RotateVec(z, y, t1, c1, s1); camera = RotateVec(camera, y, t1, c1, s1); gpu.Launch(RotateDirection, launchParam, dirDevPtr, x, t2, c2, s2, width, height); y = RotateVec(y, x, t2, c2, s2); z = RotateVec(z, x, t2, c2, s2); camera = RotateVec(camera, x, t2, c2, s2); Gpu.Copy(dirDevMem, directions); x = D(x, L(x)); y = D(y, L(y)); z = D(z, L(z)); ScreenDivider.Panel2.Invalidate(); } mouseLocation = new int2(e.X, e.Y); }
public static float3 RotateZ(float3 z, float t) { float3 p = z; float s = DeviceFunction.Sin(t); float c = DeviceFunction.Cos(t); p.x = c * z.x + s * z.y; p.y = c * z.y - s * z.x; return(p); }
public static float3 RotateX(float3 z, float t) { float3 p = z; float s = DeviceFunction.Sin(t); float c = DeviceFunction.Cos(t); p.y = c * z.y + s * z.z; p.z = c * z.z - s * z.y; return(p); }
public static float3 RotateY(float3 z, float t) { float3 p = z; float s = DeviceFunction.Sin(t); float c = DeviceFunction.Cos(t); p.x = c * z.x - s * z.z; p.z = c * z.z + s * z.x; return(p); }
private static double CalkaGPU(double x, double y) { //cos(x) + sin(x*y) + 0.1*x^2 - 2*y^2 return(DeviceFunction.Cos(x) + DeviceFunction.Sin(x * y) + 0.1 * x * x - 2 * y * y); }