File:Particle2dmotion.svg
From Wikipedia, the free encyclopedia
Jump to navigation
Jump to search
Size of this PNG preview of this SVG file: 800 × 500 pixels. Other resolutions: 320 × 200 pixels | 640 × 400 pixels | 1,024 × 640 pixels | 1,280 × 800 pixels | 2,560 × 1,600 pixels | 1,600 × 1,000 pixels.
Original file (SVG file, nominally 1,600 × 1,000 pixels, file size: 1.74 MB)
This is a file from the Wikimedia Commons. Information from its description page there is shown below.
Commons is a freely licensed media file repository. You can help.
Commons is a freely licensed media file repository. You can help.
Summary
| DescriptionParticle2dmotion.svg |
English: Belief distributions for a non-sensing robot after moving for several steps in two dimensions. The diagram was generated using the following c++ code, hereby licensed under the same license as the diagram itself:
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <fstream>
#include <sstream>
using namespace std;
const int M = 2000;
const long double
ANGLE_NOISE = 0.04,
ANGLE_P_NOISE = 0.0002,
ANGLE_R_NOISE = 0.02,
R_NOISE = 3,
R_P_NOISE = 0.008,
PI = 3.1415926535897932384626433832795028;
struct particle {
long double x, y;
long double theta;
};
vector<particle>z;
particle qwer;
fstream fout("particle2d.svg", fstream::out);
ostringstream poly;
inline long double noise() {
return (rand()/(long double)RAND_MAX) - (rand()/(long double)RAND_MAX) + (rand()/(long double)RAND_MAX) - (rand()/(long double)RAND_MAX);
}
void move(long double r, long double t) {
qwer.theta += t;
qwer.x += r*cos(qwer.theta);
qwer.y += r*sin(qwer.theta);
for(int i=0; i<M; i++) {
z[i].theta += t + r*ANGLE_P_NOISE*noise() + ANGLE_NOISE*noise() + t*ANGLE_R_NOISE*noise();
z[i].x += r*cos(z[i].theta) + R_NOISE*noise() + r*R_P_NOISE*noise();
z[i].y += r*sin(z[i].theta) + R_NOISE*noise() + r*R_P_NOISE*noise();
fout << " <circle cx='" << z[i].x << "' cy='" << z[i].y << "' r='1' style='fill:#000;opacity:0.8;'/>" << endl;
}
fout << " <circle cx='" << qwer.x << "' cy='" << qwer.y << "' r='6' style='fill:#f30;'/>" << endl;
fout << " <path d='M" << qwer.x - r/2.4*cos(qwer.theta) << "," << qwer.y - r/2.4*sin(qwer.theta)
<< "L" << qwer.x - r/2*cos(qwer.theta - 0.05) << "," << qwer.y - r/2*sin(qwer.theta - 0.05)
<< "L" << qwer.x - r/2*cos(qwer.theta + 0.05) << "," << qwer.y - r/2*sin(qwer.theta + 0.05) << "' style='fill:#f30;'/>" << endl;
poly << qwer.x << ',' << qwer.y << ' ';
}
int main() {
particle start;
start.x = 800;
start.y = 100;
start.theta = 0;
qwer = start;
for(int i=0; i<M; i++) {
z.push_back(start);
}
fout << "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='1600px' height='1000px'>" << endl;
fout << " <circle cx='" << qwer.x << "' cy='" << qwer.y << "' r='5' style='fill:#f30;'/>" << endl;
poly << qwer.x << ',' << qwer.y << ' ';
move(200, 0);
move(200, 0);
move(200, 0);
move(200, PI/2);
move(200, 0);
move(200, 0);
move(200, PI/2);
move(200, 0);
move(200, 0);
move(200, 0);
move(200, 0);
move(200, 0);
fout << "<polyline points='" << poly.str() << "' style='fill:none;stroke:#f30;stroke-width:2px' />" << endl;
fout << "</svg>" << endl;
fout.close();
}
|
| Date | |
| Source | Own work |
| Author | Daniel Lu |
| SVG development InfoField |
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Captions
Add a one-line explanation of what this file represents
Items portrayed in this file
depicts
some value
25 March 2013
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 07:57, 25 March 2013 | No thumbnail | 1,600 × 1,000 (1.74 MB) | wikimediacommons>Dllu | User created page with UploadWizard |
File usage
The following 2 pages use this file:
Metadata
This file contains additional information, probably added from the digital camera or scanner used to create or digitize it.
If the file has been modified from its original state, some details may not fully reflect the modified file.
| Width | 1600px |
|---|---|
| Height | 1000px |
Retrieved from "http://70.231.62.181/index.php/File:Particle2dmotion.svg"