对两个 xyz 坐标文件进行线性插值的程序

此代码用于对两个 xyz 坐标文件(即 C  0.0  0.1  0.2 这种形式的)进行线性插值。对于几何构型优化问题,如果很难得到最优结构,则可以使用目标结构的两个相邻结构进行线性插值,从而得到最优结构的较好的初始猜测。

程序总共有三个代码文件组成。类的实现没有写成单独的文件。程序会输出 Geom_#.xyz 这样一系列插值结构文件。

---------- DispVec.h ----------

/*
 * Displacement vector definition
*/

#ifndef DISPLACEMENT_VECTOR_H
#define DISPLACEMENT_VECTOR_H

#include <iostream>
#include <stdexcept>
#include <iomanip>

class DispVec
{
public:
    DispVec() {}
    DispVec(double x, double y, double z)
    {
        X = x;
        Y = y;
        Z = z;
    }
    DispVec(const DispVec& rhs)
    {
        X = rhs.X;
        Y = rhs.Y;
        Z = rhs.Z;
    }
    DispVec& operator=(const DispVec& rhs)
    {
        if(this != &rhs)
        {
            X = rhs.X;
            Y = rhs.Y;
            Z = rhs.Z;
        }
        return *this;
    }
    friend DispVec operator-(const DispVec& lhs, const DispVec& rhs)
    {
        DispVec result;
        result.X = lhs.X - rhs.X;
        result.Y = lhs.Y - rhs.Y;
        result.Z = lhs.Z - rhs.Z;
        return result;
    }
    friend DispVec operator+(const DispVec& lhs, const DispVec& rhs)
    {
        DispVec result;
        result.X = lhs.X + rhs.X;
        result.Y = lhs.Y + rhs.Y;
        result.Z = lhs.Z + rhs.Z;
        return result;
    }
    DispVec& operator+=(const DispVec& rhs)
    {
        X += rhs.X;
        Y += rhs.Y;
        Z += rhs.Z;
        return *this;
    }
    DispVec& operator-=(const DispVec& rhs)
    {
 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值