src
fields2cover
objectives
sg_obj
n_swath_modified.cpp
Go to the documentation of this file.
1
//=============================================================================
2
// Copyright (C) 2021-2024 Wageningen University - All Rights Reserved
3
// Author: Gonzalo Mier
4
// BSD-3 License
5
//=============================================================================
6
7
#include "
fields2cover/objectives/sg_obj/n_swath_modified.h
"
8
9
namespace
f2c::obj
{
10
11
double
NSwathModified::computeCost
(
12
double
ang,
double
op_width,
const
F2CCell
&
cell
) {
13
if
(
cell
.isEmpty() || op_width <= 0.0) {
14
return
0.0;
15
}
16
double
n_turns {0.0};
17
for
(
auto
&&
ring
:
cell
) {
18
for
(
size_t
i = 0; i <
ring
.size(); ++i) {
19
auto
p =
ring
.getGeometry(i);
20
auto
p_1 =
ring
.getGeometry((i - 1) %
ring
.size());
21
n_turns += p.distance(p_1) *
22
fabs(sin(ang - (p - p_1).getAngleFromPoint()));
23
}
24
}
25
return
n_turns / (2.0 * op_width);
26
}
27
28
}
// namespace f2c::obj
29
n_swath_modified.h
1_basic_types.cell
cell
Definition:
1_basic_types.py:88
f2c::types::Cell
Definition:
Cell.h:32
f2c::obj
Objective algorithms' namespace.
Definition:
base_objective.h:14
1_basic_types.ring
ring
Definition:
1_basic_types.py:68
f2c::obj::NSwathModified::computeCost
double computeCost(double ang, double op_width, const F2CCell &cell) override
Compute the cost function.
Definition:
n_swath_modified.cpp:11
fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31