Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm developing a little 2D game and i have to predict when and where things will collide.
So, i've got four Vector2 :
A position
B position
A linear velocity
B linear velocity
I have to find if they intersect, where they intersect and at what time from now.
I've found many math solutions but i could't translate them into code.
The visualization of the problem, numbers are velocities
You want to compute the minimum of
norm((A+t*vA)-(B+t*vB))=norm((A-B)+t*(vA-vB))
Taking the square of these Euclidean norms
norm((A-B)+t*(vA-vB))^2 = norm(A-B)^2 + 2*t*dot(A-B,vA-vB) + t^2*norm(vA-vB)^2
gives you a simple quadratic function in t where the minimum has the value
min_dist =norm(A-B)^2 - dot(A-B,vA-vB)^2/norm(vA-vB)^2
at time
t = -dot(A-B,vA-vB)/norm(vA-vB)^2
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am using hist(x_new,freq = FALSE) command to plot histogram, but the probability density exceed the value unity.
Probability density is not the same thing as probability. Densities are not in general bounded by 1. The point is that the total area under the density is 1, which is completely consistent with portions of it being above 1. In fact, it is quite common for a density function (or density histogram) to be above 1 in some places.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have for example 4 points: A (latitute1, longitude1), B (latitute2, longitude2), C (latitute3, longitude3), D (latitute4, longitude4).
If I am a driver and I go from point A, I need an algorithm that calculates the most efficient way for me to visit all the points B, C, D starting from A. So that the distance is the smallest possible.
The algorithm should tell me the most effective order: A --> C --> B --> D (for example).
What matters is the total distance traveled is the lowest possible.
Thanks so much!!! :)
Maybe look into Dijkstras algorithm?
https://en.m.wikipedia.org/wiki/Dijkstra%27s_algorithm
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
For one of my projects I would like to create several random matrices, which have full rank. Does anybody know a quick way to do this in R or has an idea how to proceed?
You are overwhelmingly likely to get a full-rank matrix if you generate a matrix with iid elements, with no additional constraints:
library(Matrix)
set.seed(101)
r <- replicate(1000,rankMatrix(matrix(rnorm(10000),100)))
table(r) ## all values are equal to 100
(Someone who spent more time on the math might be able to prove that the set of reduced-rank matrices within this space of matrices actually has measure 0 ...)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
An input sequence is given. Each stage of the iteration finds another sequence by calculating difference between n-i and n-i-1 number. We continue the process and at the end of the last iteration (iteration: n-1) we find only 1 number. What is the mathematical formulation for finding the last number as shown in the image?
Basically, the mathematical formulation is finding the n-1'th derivative of the degree-n-1 polynomial passing through all points (i,arr[i]). That derivative is guaranteed to be a constant. This is equivalent to the coefficient of the term with exponent n-1, divided by (n-1)!.
This method is a special case of what is known as Neville's Algorithm.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I would like to implement a revolve tool for 2d splines in 3d. The geometry computation already works but the normals are a bit tricky.
The problem is the angle between 2 points like the following image:
Here P1 is the previous point P2 the current point and P3 the next point.
How would I calculate the vector N.
Are you looking for the inverse angle bisector?
dir1 = normalize(p1 - p2)
dir2 = normalize(p3 - p2)
n = normalize(-dir1 - dir2)