Download Project Assignment I:

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Laplace–Runge–Lenz vector wikipedia , lookup

Renormalization wikipedia , lookup

Path integral formulation wikipedia , lookup

Propagator wikipedia , lookup

Atomic theory wikipedia , lookup

Relativistic quantum mechanics wikipedia , lookup

Mean field particle methods wikipedia , lookup

Particle filter wikipedia , lookup

Transcript
Project Assignment I: due March 27, 2006
Problem 1: The following Matlab program takes an integer n as input, generates n
uniformly chosen random points on the unit circle in 2D, and plots them.
function [y] = uniformRandomPointsOnUnitCircle(n)
% uniformRandomPointsOnUnitCircle(n) generates n uniformly chosen
% random points on a unit circle.
x = randn(n,2);
for i = 1: n, y(i,:) = x(i,:)/norm(x(i,:)); end
plot(y(:,1),y(:,2),'.'); axis('square');
First type this program into a file with name “uniformRandomPointsOnUnitCircle.m”
Then start a matlab environment.
1. Use “help path” to learn how to set path in a matlab environment.
2. Run “[y] = uniformRandomPointsOnUnitCircle(100);” to see the execution of this
program.
3. Use “help plot” to learn the plot function in matlab.
4. Use “help randn” to learn about the randn function in matlab.
5. Use “help for” to learn about the “for” construct.
6. Use “help plot3” to learn to 3D plot in matlab.
7. As the main part of this problem, design a matlab program that takes an
integer n as input, generates n uniformly chosen random points on the unit
sphere in 3D, and plots them. You should use the rotate function to rotate
your 3D plot.
Problem 2. Write the code for the following problems. The input of the problem has
four parameters: m, n, R, B, where m and n are positive integers, R is an (m by 2) matrix,
and B is an (n by 2) matrix. We can view R as a set of m points in two dimensions and B
as a set of n points in two dimensions. Your program should do the following:
1. Plot points in R with red color and plot points in B with blue color.
2. For every point in R, compute the two nearest neighbors of that point in B. This
output can be expressed by an (m by 2) integer matrix storing the indices of the
two nearest neighbors of every point in R.
3. Plot the line segment with an arrow from each point R to their two nearest
neighbors in B.
[Hint: You can implement the O(n2) algorithm.]
Problem 3. Write a program for the following task. The inputs to your algorithm include
 p1 
p 
1. a point-set matrix P   2  of dimensions n by 2 (that is, the point-set has n
 
 
 pn 
points in two dimensions),
2. a mass vector M  m1 , m2 ,..., mn  of n real numbers,
3.
4.
5.
6.
 v1 
v 
a velocity vector V   2  of n two-dimensional vectors,

 
v n 
a real-number parameter epsilon,
a real time-step parameter delta, and
an integer k specifies the number of time-steps.
The input describes a particle system (often called an N-Body system) in two dimensions:
The ith particle has mass mi. Initially at time T = 0, the ith particle is located at pi and has
initial velocity vi. We assume the following rule for pair-wise gravitational forces:
For any i, and j,
1. if p i  p j 2  epsilon , then these two particles mutually put a pulling-force of
magnitude
2.
mi m j
pi  p j
to each other. The is, particle i puts a force on particle j of
2
this magnitude along the directions of the line segment from pj to pi and particle
j puts a force on particle i of this magnitude along the directions of the line
segment from from pi to pj ;
if pi  p j 2  epsilon , then these two particles mutually put a expelling-force of
magnitude
mi m j
pi  p j
to each other. That is, particle i puts a force on particle j of
2
this magnitude along the directions of the line segment from pi to pj ; and particle
j puts a force on particle i of this magnitude along the directions of the line
segment from pj to pi ;
So at each time step, each particle i receives n-1 forces, each is a two dimensional vector.
Let Fi denote the vector sum of all forces put on particle i, which causes particle i to
accelerate at ai  Fi / mi . So the new location and new velocity of particle i at the end of
the next time-step is pi  pi  vi  delta and vi  vi  ai  delta .
Your program should compute the new locations and velocities after each time-step for k
time-steps. Use a simple graphics interface (for example, in matlab you can use plot
function) to show an animation of the motions of these particles.