⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vector.cpp

📁 Cal3D实现虚拟角色 Cal3D实现虚拟角色
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//****************************************************************************//// vector.cpp                                                                 //// Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger                       ////****************************************************************************//// This library is free software; you can redistribute it and/or modify it    //// under the terms of the GNU Lesser General Public License as published by   //// the Free Software Foundation; either version 2.1 of the License, or (at    //// your option) any later version.                                            ////****************************************************************************//#ifdef HAVE_CONFIG_H#include "config.h"#endif//****************************************************************************//// Includes                                                                   ////****************************************************************************//#include "cal3d/vector.h"#include "cal3d/matrix.h"#include "cal3d/quaternion.h" /*****************************************************************************//** Constructs the vector instance.  *  * This function is the default constructor of the vector instance.  *****************************************************************************//*CalVector::CalVector()  : x(0.0f), y(0.0f), z(0.0f){}*/ /*****************************************************************************//** Constructs the vector instance.  *  * This function is a constructor of the vector instance.  *  * @param v The vector to construct this vector instance from.  *****************************************************************************//*CalVector::CalVector(const CalVector& v)  : x(v.x), y(v.y), z(v.z){}*/ /*****************************************************************************//** Constructs the vector instance.  *  * This function is a constructor of the vector instance.  *  * @param vx The x component.  * @param vy The y component.  * @param vz The z component.  *****************************************************************************//*CalVector::CalVector(float vx, float vy, float vz)  : x(vx), y(vy), z(vz){}*/ /*****************************************************************************//** Destructs the vector instance.  *  * This function is the destructor of the vector instance.  *****************************************************************************//*CalVector::~CalVector(){}*/ /*****************************************************************************//** Provides access to the components of the vector instance.  *  * This function provides read and write access to the three components of the  * vector instance.  *  * @param i The index to the specific component.  *  * @return A reference to the specific component.  *****************************************************************************//*float& CalVector::operator[](unsigned int i){  return (&x)[i];}*/ /*****************************************************************************//** Provides access to the components of the vector instance.  *  * This function provides read access to the three components of the vector  * instance.  *  * @param i The index to the specific component.  *  * @return A constant reference to the specific component.  *****************************************************************************//*const float& CalVector::operator[](unsigned int i) const{  return (&x)[i];}*/ /*****************************************************************************//** Equates the vector instance with another vector.  *  * This operator equates the vector instance with another vector.  *  * @param v The vector to equate the vector instance with.  *****************************************************************************//*void CalVector::operator=(const CalVector& v){  x = v.x;  y = v.y;  z = v.z;}*/ /*****************************************************************************//** Adds another vector to the vector instance.  *  * This operator adds another vector to the vector instance.  *  * @param v The vector to be added.  *****************************************************************************//*void CalVector::operator+=(const CalVector& v){  x += v.x;  y += v.y;  z += v.z;}*/ /*****************************************************************************//** Subtracts another vector from the vector instance.  *  * This operator subtracts another vector from the vector instance.  *  * @param v The vector to be subtracted.  *****************************************************************************//*void CalVector::operator-=(const CalVector& v){  x -= v.x;  y -= v.y;  z -= v.z;}*/ /*****************************************************************************//** Scales the vector instance.  *  * This operator scales the vector instance by multiplying its components by  * a specific factor.  *  * @param d The factor to multiply the vector components by.  *****************************************************************************//*void CalVector::operator*=(const float d){  x *= d;  y *= d;  z *= d;}*/ /*****************************************************************************//** Transforms the vector instance by a quaternion.  *  * This function transforms the vector instance by a given quaternion.  *  * @param q The quaternion to be used for the transformation.  *****************************************************************************/void CalVector::operator*=(const CalQuaternion& q){  CalQuaternion temp(-q.x, -q.y, -q.z, q.w);  temp *= *this;  temp *= q;  x = temp.x;  y = temp.y;  z = temp.z;} /*****************************************************************************//** Transforms the vector instance by a matrix.  *  * This function transforms the vector instance by a given matrix.  *  * @param m The matrix to be used for the transformation.  *****************************************************************************//*void CalVector::operator*=(const CalMatrix& m){  float ox = x;  float oy = y;  float oz = z;  x = m.dxdx*ox + m.dxdy*oy + m.dxdz*oz;  y = m.dydx*ox + m.dydy*oy + m.dydz*oz;  z = m.dzdx*ox + m.dzdy*oy + m.dzdz*oz;}*/ /*****************************************************************************//** Scales the vector instance.  *  * This operator scales the vector instance by dividing its components by a  * specific factor.  *  * @param d The factor to divide the vector components by.  *****************************************************************************//*void CalVector::operator/=(const float d){  x /= d;  y /= d;  z /= d;}*/ /*****************************************************************************//** Tests the equality of 2 vectors  *  * This operator checks to see if 2 vectors are equal  *  * @param v The vector to be tested against.  *****************************************************************************//*bool CalVector::operator==(const CalVector& v){  return ((x == v.x) && (y == v.y) && (z == v.z));}*/ /*****************************************************************************//** Calculates the sum of two vectors.  *  * This operator calculates the sum of two vectors.  *  * @param v The first vector to be added.  * @param u The second vector to be added.  *  * @return The sum of the two vectors.  *****************************************************************************//*CalVector operator+(const CalVector& v, const CalVector& u){  return CalVector(v.x + u.x, v.y + u.y, v.z + u.z);}*/ /*****************************************************************************//** Calculates the difference of two vectors.  *  * This operator calculates the difference of two vectors.  *  * @param v The first vector to be added.  * @param u The second vector to be subtracted.  *  * @return The difference of the two vectors.  *****************************************************************************//*CalVector operator-(const CalVector& v, const CalVector& u)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -