Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Windows;
|
---|
4 | using Microsoft.Research.DynamicDataDisplay.Charts.Filters;
|
---|
5 |
|
---|
6 | namespace Microsoft.Research.DynamicDataDisplay.Filters
|
---|
7 | {
|
---|
8 | [Obsolete("Works incorrectly", true)]
|
---|
9 | public sealed class InclinationFilter : PointsFilterBase
|
---|
10 | {
|
---|
11 | private double criticalAngle = 179;
|
---|
12 | public double CriticalAngle
|
---|
13 | {
|
---|
14 | get { return criticalAngle; }
|
---|
15 | set
|
---|
16 | {
|
---|
17 | if (criticalAngle != value)
|
---|
18 | {
|
---|
19 | criticalAngle = value;
|
---|
20 | RaiseChanged();
|
---|
21 | }
|
---|
22 | }
|
---|
23 | }
|
---|
24 |
|
---|
25 | #region IPointFilter Members
|
---|
26 |
|
---|
27 | public override List<Point> Filter(List<Point> points)
|
---|
28 | {
|
---|
29 | if (points.Count == 0)
|
---|
30 | return points;
|
---|
31 |
|
---|
32 | List<Point> res = new List<Point> { points[0] };
|
---|
33 |
|
---|
34 | int i = 1;
|
---|
35 | while (i < points.Count)
|
---|
36 | {
|
---|
37 | bool added = false;
|
---|
38 | int j = i;
|
---|
39 | while (!added && (j < points.Count - 1))
|
---|
40 | {
|
---|
41 | Point x1 = res[res.Count - 1];
|
---|
42 | Point x2 = points[j];
|
---|
43 | Point x3 = points[j + 1];
|
---|
44 |
|
---|
45 | double a = (x1 - x2).Length;
|
---|
46 | double b = (x2 - x3).Length;
|
---|
47 | double c = (x1 - x3).Length;
|
---|
48 |
|
---|
49 | double angle13 = Math.Acos((a * a + b * b - c * c) / (2 * a * b));
|
---|
50 | double degrees = 180 / Math.PI * angle13;
|
---|
51 | if (degrees < criticalAngle)
|
---|
52 | {
|
---|
53 | res.Add(x2);
|
---|
54 | added = true;
|
---|
55 | i = j + 1;
|
---|
56 | }
|
---|
57 | else
|
---|
58 | {
|
---|
59 | j++;
|
---|
60 | }
|
---|
61 | }
|
---|
62 | // reached the end of resultPoints
|
---|
63 | if (!added)
|
---|
64 | {
|
---|
65 | res.Add(points.GetLast());
|
---|
66 | break;
|
---|
67 | }
|
---|
68 | }
|
---|
69 | return res;
|
---|
70 | }
|
---|
71 |
|
---|
72 | #endregion
|
---|
73 | }
|
---|
74 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.