Changeset 498a9f


Ignore:
Timestamp:
Jun 10, 2008, 11:20:12 AM (17 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
233e33
Parents:
3dfad8
Message:

some new functions: vector::vector(), vector::ProjectOntoPlane(), vector::One(), vector::Init()

vector::vector() new constructor allowing for setting of components
vector::ProjectOntoPlane() projects vector onto plane described by normal vector
vector::One() sets components to given double
vector::Init() initialised components to given values

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/vector.cpp

    r3dfad8 r498a9f  
    1313 */
    1414vector::vector() { x[0] = x[1] = x[2] = 0.; };
     15
     16/** Constructor of class vector.
     17 */
     18vector::vector(double x1, double x2, double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };
    1519
    1620/** Desctructor of class vector.
     
    111115};
    112116
     117/** projects this vector onto plane defined by \a *y.
     118 * \param *y array to normal vector of plane
     119 * \return \f$\langle x, y \rangle\f$
     120 */
     121void vector::ProjectOntoPlane(const vector *y)
     122{
     123  vector tmp;
     124  tmp.CopyVector(y);
     125  tmp.Scale(Projection(y));
     126  this->SubtractVector(&tmp);
     127};
     128
    113129/** Calculates the projection of a vector onto another \a *y.
    114130 * \param *y array to second vector
     
    117133double vector::Projection(const vector *y) const
    118134{
    119   return (ScalarProduct(y)/Norm()/y->Norm());
     135  return (ScalarProduct(y));
    120136};
    121137
     
    150166};
    151167
     168/** Zeros all components of this vector.
     169 */
     170void vector::One(double one)
     171{
     172  for (int i=NDIM;i--;)
     173    this->x[i] = one;
     174};
     175
     176/** Initialises all components of this vector.
     177 */
     178void vector::Init(double x1, double x2, double x3)
     179{
     180  x[0] = x1;
     181  x[1] = x2;
     182  x[2] = x3;
     183};
     184
    152185/** Calculates the angle between this and another vector.
    153186 * \param *y array to second vector
    154  * \return \f$\frac{\langle x, y \rangle}{|x||y|}\f$
     187 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$
    155188 */
    156189double vector::Angle(vector *y) const
    157190{
    158   return (this->ScalarProduct(y)/(this->Norm()*y->Norm()));
     191  return acos(this->ScalarProduct(y)/Norm()/y->Norm());
    159192};
    160193
  • src/vector.hpp

    r3dfad8 r498a9f  
    1010
    1111  vector();
     12  vector(double x1, double x2, double x3);
    1213  ~vector();
    1314
     
    2324  void CopyVector(const vector *y);
    2425  void RotateVector(const vector *y, const double alpha);
     26  void ProjectOntoPlane(const vector *y);
    2527  void Zero();
     28  void One(double one);
     29  void Init(double x1, double x2, double x3);
    2630  void Normalize();
    2731  void Translate(const vector *x);
Note: See TracChangeset for help on using the changeset viewer.