vector.hh

来自「机器人人3D仿真工具,可以加入到Simbad仿真环境下应用。」· HH 代码 · 共 187 行

HH
187
字号
/* *  Gazebo - Outdoor Multi-Robot Simulator *  Copyright (C) 2003   *     Nate Koenig & Andrew Howard * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * *//* Desc: Vector classes and functions * Author: Andrew Howard * Date: 11 Jun 2003 * CVS: $Id: Vector.hh,v 1.8 2005/11/22 16:44:51 natepak Exp $ */#ifndef GZVECTOR_H_#define GZVECTOR_H_#include <math.h>#include "Global.hh"// Basic 3 vectorstruct GzVector{  double x, y, z;};// Quatnernionstruct GzQuatern{  double u, x, y, z;};// Combined posestruct GzPose{  GzVector pos;  GzQuatern rot;};/// @brief Matrix for homogeneous transforms on 2D pointstypedef struct{  double m[3][3];} GzHomo;// Create a zero vectorGzVector GzVectorZero();// Create a vector from the given valuesGzVector GzVectorSet(double x, double y, double z);// Create a vector from a quaternionGzVector GzVectorSetQuatern(GzQuatern q);// Add one vector to another (element by element)GzVector GzVectorAdd(GzVector b, GzVector a);// Subtract one vector from another (element by element)GzVector GzVectorSub(GzVector b, GzVector a);// Mutliply vector by scalarGzVector GzVectorMul(double s, GzVector a);// Compute vector magnitudedouble GzVectorMag(GzVector a);// Normalize a vector to unit lengthGzVector GzVectorUnit(GzVector a);// Take cross product of two vectorsGzVector GzVectorCross(GzVector a, GzVector b);// Take dot product of two vectorsdouble GzVectorDot(GzVector a, GzVector b);// See if a vector is finite (e.g., not nan)bool GzVectorFinite(GzVector a);// Create an identity quaternionGzQuatern GzQuaternIdent();// Create a quaternion from elementsGzQuatern GzQuaternSet(double u, double x, double y, double z);// Create a quaternion form a vectorGzQuatern GzQuaternSetVector(GzVector v);// Invert a quaternionGzQuatern GzQuaternInverse(GzQuatern a);// Normalize a quaternionGzQuatern GzQuaternNormal(GzQuatern a);// Create a quaternion from an axis and angleGzQuatern GzQuaternFromAxis(double x, double y, double z, double a);// Create a quaternion from Euler anglesGzQuatern GzQuaternFromEuler(double roll, double pitch, double yaw);// Create a quatern from Homogeneous matrixGzQuatern GzQuaternFromHomo(GzHomo homo);// Convert quaternion to Euler angles (roll, pitch, yaw)GzVector GzQuaternToEuler(GzQuatern q);// Convert quaterion to axis and angle (x, y, z, rotation)GzQuatern GzQuaternToAxis(GzQuatern a);// Multiply two quaternionsGzQuatern GzQuaternMul(GzQuatern a, GzQuatern b);// Scale a quaternion rotationGzQuatern GzQuaternScale(double s, GzQuatern a);// See if a quaternion is finite (e.g., not nan)bool GzQuaternFinite(GzQuatern a);// Create a pose from the given position and rotationGzPose GzPoseSet(GzVector pos, GzQuatern rot);/// @brief Create a pose from a triplet of vectors./// @param pos specifies the object position./// @param at specifies the point to look at (x axis)./// @param up Specifies the "up" direction (z axis).GzPose GzPosePointAt(GzVector pos, GzVector at, GzVector up);// See if a pose is finite (e.g., not nan)bool GzPoseFinite(GzPose a);// Add one pose to another: c = b + aGzPose GzCoordPoseAdd(GzPose bpose, GzPose apose);// Subtract one pose from another: c = b - aGzPose GzCoordPoseSub(GzPose bpose, GzPose apose);// Find the inverse of a pose; i.e., if b = ba + a, given b and ba,// find aGzPose GzCoordPoseSolve(GzPose ba, GzPose b);// Add one position to another: c = b + aGzVector GzCoordPositionAdd(GzVector bpos, GzVector apos, GzQuatern arot);// Subtract one position from another: c = b - aGzVector GzCoordPositionSub(GzVector bpos, GzVector apos, GzQuatern arot);// Add one rotation to another: c = b + aGzQuatern GzCoordRotationAdd(GzQuatern b, GzQuatern a);// Subtract one rotation from another: c = b - aGzQuatern GzCoordRotationSub(GzQuatern b, GzQuatern a);/// @brief Compute a homogeneous transform matrix from a QuaternGzHomo GzHomoFromQuatern(GzQuatern q);/// @brief Compute the inverse of the given transform matrixGzHomo GzHomoInverse(GzHomo a);/// @brief Apply a homogeneous transformGzVector GzHomoMul(GzHomo m, GzVector a);#endif

⌨️ 快捷键说明

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