BioDynaMo  v1.05.119-a4ff3934
cell.cc
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #include "core/agent/cell.h"
16 
17 namespace bdm {
18 
19 const Real3 Cell::kXAxis = {1.0, 0.0, 0.0};
20 const Real3 Cell::kYAxis = {0.0, 1.0, 0.0};
21 const Real3 Cell::kZAxis = {0.0, 0.0, 1.0};
22 
23 void Cell::ApplyDisplacement(const Real3& displacement) {
24  if (displacement[0] == 0 && displacement[1] == 0 && displacement[2] == 0) {
25  return;
26  }
27 
28  UpdatePosition(displacement);
29  // Reset biological movement to 0.
30  SetTractorForce({0, 0, 0});
31 }
32 
34  auto vector_to_point = pos - position_;
35  Real3 local_cartesian{kXAxis * vector_to_point, kYAxis * vector_to_point,
36  kZAxis * vector_to_point};
37  real_t radius = std::sqrt(local_cartesian[0] * local_cartesian[0] +
38  local_cartesian[1] * local_cartesian[1] +
39  local_cartesian[2] * local_cartesian[2]);
40  return {radius, std::acos(local_cartesian[2] / radius),
41  std::atan2(local_cartesian[1], local_cartesian[0])};
42 }
43 
44 } // namespace bdm
bdm::Cell::UpdatePosition
void UpdatePosition(const Real3 &delta)
Definition: cell.h:257
bdm
Definition: agent.cc:39
bdm::real_t
double real_t
Definition: real_t.h:21
bdm::Cell::kYAxis
static const Real3 kYAxis
Second axis of the local coordinate system.
Definition: cell.h:47
bdm::Cell::TransformCoordinatesGlobalToPolar
Real3 TransformCoordinatesGlobalToPolar(const Real3 &coord) const
Definition: cell.cc:33
bdm::Cell::SetTractorForce
void SetTractorForce(const Real3 &tractor_force)
Definition: cell.h:228
bdm::Real3
MathArray< real_t, 3 > Real3
Aliases for a size 3 MathArray.
Definition: math_array.h:434
bdm::Cell::kXAxis
static const Real3 kXAxis
First axis of the local coordinate system.
Definition: cell.h:45
bdm::MathArray< real_t, 3 >
bdm::Cell::ApplyDisplacement
void ApplyDisplacement(const Real3 &displacement) override
Definition: cell.cc:23
cell.h
bdm::Cell::kZAxis
static const Real3 kZAxis
Third axis of the local coordinate system.
Definition: cell.h:49
bdm::Cell::position_
Real3 position_
NB: Use setter and don't assign values directly.
Definition: cell.h:371