project | content |
---|---|
This work belongs courses | Spring 2020 Computer Software Engineering Institute (Roger Ren Jianxin) |
Where this requirement in the job | Individual project work |
My aim in this course is | Complete a full software development experience and in a blog of recorded experience of the development process to master teamwork skills to make the product an excellent, long-lasting, meaningful |
In particular aspects of the job which helped me achieve goals | Experience "building law" in reference to performance analysis and personal software development process for project development to bring help |
Teaching classes | 006 |
project address | Intersections | q2l's GitHub |
Personal Software Process Table (PSP)
Before we start implementing the program, in the following form to record your PSP is estimated to be spent on the development of the various modules of the program period. (0.5 ')
PSP2.1 | Personal Software Process Stages | Estimated time consuming (minutes) | The actual time-consuming (minutes) |
---|---|---|---|
Planning | plan | 10 | 10 |
· Estimate | • Estimate how much time this task requires | 10 | 10 |
Development | Develop | 115 | 180 |
· Analysis | · Needs analysis (including learning new technologies) | 20 | 15 |
· Design Spec | Generate design documents | 10 | 10 |
· Design Review | · Design Review (and his colleagues reviewed the design documents) | 0 | 0 |
· Coding Standard | · Code specifications (development of appropriate norms for the current development) | 5 | 5 |
· Design | · Specific design | 10 | 20 |
· Coding | · Specific coding | 30 | 60 |
· Code Review | · Code Review | 10 | 10 |
· Test | · Test (self-test, modify the code, submit modifications) | 30 | 60 |
Reporting | report | 80 | 80 |
· Test Report | · testing report | 30 | 30 |
· Size Measurement | · Computing workload | 20 | 20 |
· Postmortem & Process Improvement Plan | · Hindsight, and propose process improvement plan | 30 | 30 |
total | 235 | 270 |
Problem-solving ideas
Problem-solving ideas described. That is, after beginning to get the title, how to think, how to find information in the process. (3 ')
First to get the casual working, it is a geometric topics , specifically as follows:
For solving linear intersection us there are many ways, from direct violence to the matrix operation represented and so, taking into account the style and scalability of the code we do not take direct violence seek every intersection and then store the way we chose Klein Mu law solving linear equations method, the linear equation is represented as process parameters.
Specifically, each may represent a straight line to a point plus a direction parametric equation form of expression vector:
$$ Line: Point (x_0, y_0) the Vector (x_0-x_1, y_0-Y_1) $$
Using Cramer's rule can be determined by the intersection of a line segment determinant way, specific:
$$ \begin{array}{cc} a_1x+b_1y=c_1 \ a_2x+b_2y=c_2 \end{array}$$
$$D= \left[ \begin{matrix}
a_1 & b_1 \
a_2 & b_2
\end{matrix}
\right]
D_1 = \left[ \begin{matrix}
c_1 & b_1 \
c_2 & b_2
\end{matrix}
\right]
D_2 = \left[ \begin{matrix}
a_1 & c_1 \
a_2 & c_2
\end{matrix}
\right] $$
$$x=\frac{D1}{D}, ; y=\frac{D2}{D}$$
Link between the two is:
$$ \ FRAC-x_1} {x_0 y_0-Y_1} = {- \ FRAC {B} {A} $$
$$ $$ by_0 + C = ax_0
Bring simplification to verify.
So we define the structure to be stored (x, y), due to the representation unit vectors and points are the same, so no extra definition.
We can customize the library to store a definition of these structures, and on the structure of the operator overloading.
In addition, this work though inputs are integers point , but the slope of the line (ie the unit vector) is not an integer, floating point accuracy problems also take into account, where we can use the situation redefined to zero to offset a portion of the accuracy of the tape to losses.
Since this time the task is heavy, so focus on the basic question of score points for additional questions choose to give up the practice.
Design and Implementation
Design and implementation process. Including how to design code organization, such as have several classes, several functions, how the relationship between them, whether key functions need to draw a flow chart? Unit testing is how design? (4 ')
Since this operation is simple, only it defines a class of item Intersection
, and for Point
, and Vector
linear equations consisting of the class is not designed, but directly using the struct
structure to complete a series of operations.
Because they only achieved the basics, so we use only basic knowledge of linear algebra, no need at this stage presented in the form of a flow chart.
The main purpose of unit testing is the case of covering the corners , this case includes three corners:
- Parallel lines
- For purposes of parallel straight lines does not occur can be detected whether division by zero operation.
- The resulting intersection parallel to the x-axis and y-axis when the availability of the correct results.
- For purposes of parallel straight lines does not occur can be detected whether division by zero operation.
- Vertical line
- Vertical straight line of intersection just a special case, primary linear and circular calculation will be used to later, here it is reserved down.
- Vertical straight line of intersection just a special case, primary linear and circular calculation will be used to later, here it is reserved down.
- Data boundary
- Is a range of data whether the border to ensure accuracy here using
eps=1e-12
the processing accuracy of the loss of precision.
- Data amount stress test, a given data line 1000 and 50000, respectively, when in operation can be completed within the stipulated time and get the correct results.
- Is a range of data whether the border to ensure accuracy here using
For each case we have designed a number of sample unit tests to test concrete and tangible directory UnitTest
in resources
.
Performance Analysis
Improving the performance of the program recording time spent on, you describe improvement ideas and show a performance analysis chart (VS generated automatically by a performance analysis tool of 2019), and show you consume the maximum program function. (3 ')
Ways to Improve
For my implementation, improved line is this:
- Start using a
Set
structure, since the number of intersection points is calculated without repeating.
- Analysis of
Set
performance data structure, its interior is a red-black tree implementation, a red-black tree can always guarantee an ordered state, but should always maintain, each time to find whether the existing intersection and the time it takes to related story , substantially alllog(cnt_n)
of whichcnt_n
the number is already stored in the intersection.
- Try to use
Hashset
,HashSet
the implementation is achieved inside the tub and the hash table, each element is stored into a first barrel, the barrel elements are connected by a hash table.
- Try
List
plusSort
addUnique
new features, a screen out duplicate data at the end.
Performance analysis chart
Code Description
void Intersection::solveLineLineIntersection() {
int i, j, n, ssize;
Vector u, v, w;
n = (int) vectors.size();
ssize = (int) intersects.size();
for (i = 0; i < n; i++) {
for (j = i + 1; j < n; j++) {
u = points[i] - points[j];
v = vectors[i];
w = vectors[j];
double denominator = Cross(v, w);
if (dcmp(denominator) == 0) { // parallel case
continue;
}
double t = 1.0 * Cross(w, u) / denominator;
intersects.push_back(points[i] + v * t);
}
}
}
Namely the use of the Kerem law to solve achieve a straight line intersection.