summaryrefslogtreecommitdiff
path: root/reference_points.e
diff options
context:
space:
mode:
Diffstat (limited to 'reference_points.e')
-rw-r--r--reference_points.e189
1 files changed, 131 insertions, 58 deletions
diff --git a/reference_points.e b/reference_points.e
index 8059108..ff5237f 100644
--- a/reference_points.e
+++ b/reference_points.e
@@ -6,28 +6,94 @@ create {CALIBRATION}
make
feature {}
- make is
+ default_capacity: INTEGER is 10
+
+ make(nb_parameters_: INTEGER) is
+ local
+ i: INTEGER
+ tmp: FAST_ARRAY[INTEGER]
do
- create x_device_points.with_capacity(10)
- create y_device_points.with_capacity(10)
- create x_display_points.with_capacity(10)
- create y_display_points.with_capacity(10)
+ create x_target_points.with_capacity(default_capacity)
+ create y_target_points.with_capacity(default_capacity)
+ create x_measure_points.with_capacity(default_capacity)
+ create y_measure_points.with_capacity(default_capacity)
+ from
+ nb_parameters := nb_parameters_
+ create parameters.with_capacity(nb_parameters)
+ i := 0
+ until
+ i >= nb_parameters
+ loop
+ create tmp.with_capacity(default_capacity)
+ parameters.add_last(tmp)
+ i := i + 1
+ end
+ ensure
+ nb_parameters = nb_parameters_
end
feature {ANY}
- add_point(x_device, y_device, x_display, y_display: INTEGER) is
+ add_point(a_x_target, a_y_target: INTEGER; a_x_measure, a_y_measure: INTEGER; parameters_values: FAST_ARRAY[INTEGER]) is
+ require
+ parameters_values.count = nb_parameters
+ local
+ i: INTEGER
do
- x_device_points.add_last(x_device)
- y_device_points.add_last(y_device)
- x_display_points.add_last(x_display)
- y_display_points.add_last(y_display)
+ x_target_points.add_last(a_x_target)
+ y_target_points.add_last(a_y_target)
+ x_measure_points.add_last(a_x_measure)
+ y_measure_points.add_last(a_y_measure)
+ from
+ i := parameters.lower
+ until
+ i > parameters.upper
+ loop
+ parameters.item(i).add_last(parameters_values.item(i))
+ i := i + 1
+ end
ensure
count = old count + 1
end
count: INTEGER is
do
- Result := x_device_points.count
+ Result := x_target_points.count
+ end
+
+ x_target(point: INTEGER): INTEGER is
+ require
+ point.in_range(0, count - 1)
+ do
+ Result := x_target_points.item(point)
+ end
+
+ y_target(point: INTEGER): INTEGER is
+ require
+ point.in_range(0, count - 1)
+ do
+ Result := y_target_points.item(point)
+ end
+
+ x_measure(point: INTEGER): INTEGER is
+ require
+ point.in_range(0, count - 1)
+ do
+ Result := x_measure_points.item(point)
+ end
+
+ y_measure(point: INTEGER): INTEGER is
+ require
+ point.in_range(0, count - 1)
+ do
+ Result := y_measure_points.item(point)
+ end
+
+ parameter_value(point, param: INTEGER): INTEGER is
+ require
+ point.in_range(0, count - 1)
+ param.in_range(0, nb_parameters - 1)
+ do
+ Result := parameters.item(param).item(point)
end
find_best_pair_for(x, y: INTEGER) is
@@ -42,62 +108,69 @@ feature {ANY}
i1, i2: INTEGER
x1, y1, x2, y2: INTEGER
do
- from
- i1 := x_device_points.upper
- d_min := Maximum_integer_64
- until
- i1 < x_device_points.lower
- loop
- x1 := x_device_points.item(i1)
- d1 := x1 - x
- d1 := d1 * d1
- y1 := y_device_points.item(i1)
- tmp := y1 - y
- d1 := d1 + tmp * tmp
- if d1 < d_min then
- from
- i2 := i1 - 1
- until
- i2 < x_device_points.lower
- loop
- x2 := x_device_points.item(i2)
- y2 := y_device_points.item(i2)
- if ((x1 < x) xor (x2 < x)) and then
- ((y1 < y) xor (y2 < y)) then
- d2 := x2 - x
- tmp := y2 - y
- d2 := d2 * d2 + tmp * tmp + d1
- if d2 < d_min then
- d_min := d2
- p1 := i1
- p2 := i2
- end
- end
- i2 := i2 - 1
- end
- end
- i1 := i1 - 1
- end
+-- from
+-- i1 := x_device_points.upper
+-- d_min := Maximum_integer_64
+-- until
+-- i1 < x_device_points.lower
+-- loop
+-- x1 := x_device_points.item(i1)
+-- d1 := x1 - x
+-- d1 := d1 * d1
+-- y1 := y_device_points.item(i1)
+-- tmp := y1 - y
+-- d1 := d1 + tmp * tmp
+-- if d1 < d_min then
+-- from
+-- i2 := i1 - 1
+-- until
+-- i2 < x_device_points.lower
+-- loop
+-- x2 := x_device_points.item(i2)
+-- y2 := y_device_points.item(i2)
+-- if ((x1 < x) xor (x2 < x)) and then
+-- ((y1 < y) xor (y2 < y)) then
+-- d2 := x2 - x
+-- tmp := y2 - y
+-- d2 := d2 * d2 + tmp * tmp + d1
+-- if d2 < d_min then
+-- d_min := d2
+-- p1 := i1
+-- p2 := i2
+-- end
+-- end
+-- i2 := i2 - 1
+-- end
+-- end
+-- i1 := i1 - 1
+-- end
-- *** le cas où on ne peut pas trouver un point de chaque
-- coté n'est pas géré
-- *** a la fin, il faudrait renseigner last_*
end
- last_point1_x, last_point1_y: INTEGER
- -- Answer point for `find_best_pair_for'
+-- last_point1_x, last_point1_y: INTEGER
+-- -- Answer point for `find_best_pair_for'
+
+-- last_point2_x, last_point2_y: INTEGER
+-- -- Answer point for `find_best_pair_for'
- last_point2_x, last_point2_y: INTEGER
- -- Answer point for `find_best_pair_for'
-
feature {}
- x_device_points, y_device_points: FAST_ARRAY[INTEGER]
+ nb_parameters: INTEGER
+
+ x_target_points, y_target_points: FAST_ARRAY[INTEGER]
+ -- in device coordinates
- x_display_points, y_display_points: FAST_ARRAY[INTEGER]
+ x_measure_points, y_measure_points: FAST_ARRAY[INTEGER]
+ parameters: FAST_ARRAY[FAST_ARRAY[INTEGER]]
+
invariant
- x_display_points.count = count
- y_display_points.count = count
- x_device_points.count = count
- y_device_points.count = count
+ x_target_points.count = count
+ y_target_points.count = count
+ x_measure_points.count = count
+ y_measure_points.count = count
+
+ parameters.count = nb_parameters
end