Unit – How to use the mouse to exert force in direction and / or touch input direction and input speed?

I have to object. I can move object 1 (my player) with the mouse (or touch for smartphone version).

I want to exert a force on object 2 when object 1 hits it. The force direction must be the mouse vector direction or the touch vector direction.

For mouse input, I use the event OnMouseDown and OnMouseDrag to determine the original position of the mouse.

But I think that's not the best approach. Behavior is not what I expect

void OnMouseDown ()

mouseDragStartPosition = Input.mousePosition;

// Convert the position of the cubes from the world to Screen Point
screenSpace = Camera.main.WorldToScreenPoint (transform.position);

// Compute the difference between the cube's world position and the mouse's screen position, which has been converted to a world point
offset = transform.position - Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenSpace.z));


void OnMouseDrag ()

// track the mouse position
var curScreenSpace = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenSpace.z);

// convert the mouse position of the screen to a world point and adjust it with offset
var curPosition = Camera.main.ScreenToWorldPoint (curScreenSpace) + offset;

transform.position = new Vector3 (curPosition.x, ClampY, curPosition.z);

void OnCollisionEnter (collision collision)
Debug.Log ("OnCollisionEnter");
if (collision.collider.tag == "Disc")
ApplyForce ();


void ApplyForce ()
Vector3 direction = mouseDragStartPosition - Input.mousePosition;
direction = new Vector3 (direction.x, ClampY, direction.z); // used ClampY to disallow + -Y
DiscRb.AddForce (direction * 1, ForceMode.Impulse);

Enter image description here

numerics – Calculates the distance between two points and determines the direction

I program a molecular dynamic program with periodic boundary conditions. Here I have a problem:

I have a list of coordinates like

list = RandomReal[{0, 1}, {5, 2}]

And now I want to have the distances.

I'm doing that

EuclideanDistance @@@ subsets[list, {2}]

But now I do not know the direction, so if the distance was not positive or negative to the square.
Does anyone know how to get the sign?
Because I need that for calculating my periodic boundary conditions

Google Backup and Sync – just one direction?

I'm using "Google Backup and Sync" to sync a directory on my local computer to my Google Drive store. After this The synchronization for that is complete first Time,

1) I have deleted some of the content in my browser local Directory (content already synced to Google Drive).
2) Then I added some new content to mine local Directory.
3) After that, I ran Sync again (to sync new content to Google Drive).
However, not only was the new content uploaded to my Google Drive, it also found that some of the content in my local directory was missing, and an attempt was made to download the missing content from Google Drive.
I have two questions:

1) Is there a way to reach my destination without downloading the missing content to my local computer? (ie: just sync in one direction)?
2) I need to make sure the synced content in Google Drive does not match my local directory deleted, Is it possible?

Java – A first nod in the right direction, please

I'm really after a pointer. I had an idea

I want to create a database. One that stores information about specific items. The articles have certain characteristics. Some of these properties would have parameters, variables and the database would have to do calculations, some simple algebra, some lookups, some calculations are quite complex with many stages

Everything I need is possible in Microsoft Excel. However, to organize it, many tabs and a separate workbook are required for each item.
I have no database experience, but I can program Java and have developed some Android apps for personal use. I'm also a former graphic designer and now work as an engineer for the oil and gas industry.

My dream is to have a computational database that does all of the above, but I want it to be embedded in something like SharePoint (unlike Access). I want to execute the required encoding in Java.

My question is – do I ask the impossible or can I do that?
If it does, I really want some pointers on where to start my research – and if I am in the wrong forum / on the wrong website / on the wrong website / on the wrong website / on the wrong website / on the wrong website to say where to ask.
I have what I consider to be a fantastic project – potentially a daunting task, but one that I enjoy and that I can hopefully sell as a polished package at a later date.

I would really appreciate your experience, guys.

Loyal to,


Differential equations – Streamplot gives me an empty box when drawing the direction field

I'm trying to draw the directional field for the equation $ y = e ^ {2x} + (1-2e ^ x) y + y ^ 2 $ However, it will only show an empty field when I use StreamPlot:

f[x_, y_] = Exp[2*x] + (1 - 2 * Exp[x]) y[x] + y[x]^ 2;
dfield = StreamPlot[{1, f[x, y]}, {x, -10, 10}, {y, -10, 10}]

I've made this for a few different equations and this is the first time it has not worked.

Thanks in advance for any help!

Rotational direction vector

Direction vector: Vector (X, Y, Z);

(Example, angle vector with Y = 270 * = direction vector (-0,00, -1,00, -0,00))
(Example, angle vector with Y = 90 * = direction vector (-0,00,1,00, -0,00))

How to turn this direction vector with angle vector, such. B. Vector (0,360,0)?

Algorithm – How best to transform a 2D vector into the next 8-way compass direction?

The simplest way is likely to determine the angle of the vector atan2 ()As Tetrad suggests in the comments, then scale and round it up, e.g. (Pseudo code):

// counterclockwise starting with east = 0:
enum compassDir {
E = 0, NE = 1,
N = 2, NW = 3,
W = 4, SW = 5,
S = 6, SE = 7

// for the string conversion, if you do not just z. dir.toString ():
const string[8] Headings = {"E", "NE", "N", "NW", "W", "SW", "S", "SE"};

// actual conversion code:
Float angle = atan2 (vector.y, vector.x);
int octant = round (8 * angle / (2 * PI) + 8)% 8;

compassDir dir = (compassDir) octant; // typecast to enum: 0 -> E etc.
String dirStr = Headings[octant];

The Octant = round (8 * angle / (2 * PI) + 8)% 8 Line might need an explanation. That's the case in just about every language I know atan2 () Function returns the angle in radians. Divide it by 2π convert it from radians to fractions of a full circle, and then multiply it by 8, converting it to one-eighth of a circle, then rounding it to the nearest whole number. Finally, we reduce it modulo 8 to do the wrap-around so that both 0 and 8 are correctly mapped to the east.

The reason for the + 8What I skipped above is that in some languages atan2 () can return negative results (that is, from –π to +π instead of 0 to 2π) and the modulo operator (%) can be defined to return negative values ​​for negative arguments (or its behavior for negative arguments can be undefined). Add 8th (i.e., one full turn) to input before reduction ensures that the arguments are always positive without affecting the result in any other way.

If your language does not provide a convenient function to round up the next number, you can instead use an abbreviated integer conversion and simply add 0.5 to the argument, as follows:

int octant = int (8 * angle / (2 * PI) + 8.5)% 8; // int () rounds off

Note that in some languages, Float to Integer standard conversions tend to round off negative inputs to zero rather than down. This is another reason to make sure that the input is always positive.

Of course you can replace all occurrences of 8th on that line with another number (for example, 4 or 16, or even 6 or 12 if you are on a hex map) to divide the circle in so many directions. Just adjust the enumeration / array accordingly.

Boundary Conditions – Specify the propagation direction in the 1-d wave equation in NSolve and NDSolve

I solve the 1-d wave equation with the following initial conditions:

weqn = D[u[t, x], {t, 2}]== D[u[t, x], {x, 2}];
icn = {u[0, x] == Cos[x], Derivative[1, 0][u][0, x]    == 0};
DSolveValue[{weqn, icn}, u[t, x], {t, x}]

The solution is simple as expected

1/2 (Cos[t - x] + Cos[t + x])

It is known that these two solutions correspond to waves that propagate to the right and to the left, respectively.

Now I want the same equation with the same b.c. to solve.

tmin = 0; tmax = 10; xmin = -15; xmax = 15;
NDSolve[{weqn, ic}, u, {t, tmin, tmax}, {x, xmin, xmax}]

Mathematica solves the equation and issues the following warning

Warning: An insufficient number of constraints have been specified for this
Direction of the independent variable x. Artificial edge effects can be present in
the solution

In this simple case, I know the analytic solution and can, for example, choose the solution that represents the wave that propagates to the right.

Is there a way to get Mathematica to choose this particular solution?

unity – Turning a game object in the Inspector does not change the direction

When I add a cube to a scene, the blue axis (= forward) of the cube points in a certain direction.

If I now change the Y-rotation of the cube in the inspector to 90, the blue arrow does not turn.

I would have expected it to rotate with the rotation I defined for the cube.

What's happening?

To explain more exactly why that bothers / confuses me:

I want to rebuild the RE4 inventory (which is actually 3D). The items in this inventory can be moved within the "grid":

Enter the image description here

For this I designed a suitcase and then added a weapon:

Enter the image description here

As you can see, I have correctly assigned the viewing direction: The blue axis (= forward) points in the direction of the weapon.

Now I wanted to turn the weapon so that it is displayed as in the original RE4 inventory.

For that I use a rotation of Y = -90.

The weapon now looks right:

Enter the image description here

However, in my opinion, the blue axis now points in the wrong direction. Why does not it turn with the rotation of the play object?

This really confuses me, because now, if I want to move the weapon left or right, I have to change its X position value instead of changing the Z position value.

That just seems to me to be wrong.

Can someone tell me what I miss here?

Many Thanks.

Enter the image description here

Complexity theory – satisfaction in the direction of a sequential circuit

Define a sequential circuit model as a directed graph, where each vertex is a Boolean gate. The difference is that we allow cycles in the Boolean circuit. Each cycle determines a Boolean equation.

For example, creating a loop by connecting the input and output of a negation gate results in the equation $ x = lnot x $which is not satisfactory. In such a circuit, of course, the "satisfiability" occurs in the sense. My question is:

Is the determination of whether this circuit is satisfactory known to be difficult or simple? Is it difficult or easy to find or enumerate this configuration?