-
Notifications
You must be signed in to change notification settings - Fork 28
/
sketcherMinimizerConstraintInteraction.h
42 lines (35 loc) · 1.2 KB
/
sketcherMinimizerConstraintInteraction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* sketcherMinimizerConstraintInteraction.h
*
* Created by Nicola Zonta on 7/02/2019.
* Copyright Schrodinger, LLC. All rights reserved.
*
*/
#ifndef sketcherMINIMIZERCONSTRAINTINTERACTION
#define sketcherMINIMIZERCONSTRAINTINTERACTION
#include "sketcherMinimizerInteraction.h"
static const float CONSTRAINT_SCALE = .5f;
/* force field bond stretches */
class sketcherMinimizerConstraintInteraction
: public sketcherMinimizerInteraction
{
public:
sketcherMinimizerConstraintInteraction(
sketcherMinimizerAtom* at1, const sketcherMinimizerPointF& position)
: sketcherMinimizerInteraction(at1, at1), origin(position)
{
k = CONSTRAINT_SCALE;
}
~sketcherMinimizerConstraintInteraction() override = default;
/* calculate the energy of the interaction */
void energy(float& e) override
{
e += k * sketcherMinimizerMaths::squaredDistance(atom1->coordinates,
origin);
}
/* calculate the forces and apply them */
void score(float& totalE, bool = false) override { energy(totalE); }
private:
sketcherMinimizerPointF origin;
};
#endif // sketcherMINIMIZERCONSTRAINTINTERACTION