`
xiefeifeihu
  • 浏览: 99601 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

3D向量类

 
阅读更多
隐藏行号 复制代码 源代码
  1. /*
    
  2.  * Copyright (c) 2003-2009 jMonkeyEngine
    
  3.  * All rights reserved.
    
  4.  *
    
  5.  * Redistribution and use in source and binary forms, with or without
    
  6.  * modification, are permitted provided that the following conditions are
    
  7.  * met:
    
  8.  *
    
  9.  * * Redistributions of source code must retain the above copyright
    
  10.  *   notice, this list of conditions and the following disclaimer.
    
  11.  *
    
  12.  * * Redistributions in binary form must reproduce the above copyright
    
  13.  *   notice, this list of conditions and the following disclaimer in the
    
  14.  *   documentation and/or other materials provided with the distribution.
    
  15.  *
    
  16.  * * Neither the name of 'jMonkeyEngine' nor the names of its contributors 
    
  17.  *   may be used to endorse or promote products derived from this software 
    
  18.  *   without specific prior written permission.
    
  19.  *
    
  20.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    
  21.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
    
  22.  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    
  23.  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    
  24.  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    
  25.  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    
  26.  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    
  27.  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    
  28.  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    
  29.  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    
  30.  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    
  31.  */
    
  32. 
    
  33. package com.jme.math;
    
  34. 
    
  35. import java.io.Externalizable;
    
  36. import java.io.IOException;
    
  37. import java.io.ObjectInput;
    
  38. import java.io.ObjectOutput;
    
  39. import java.util.logging.Logger;
    
  40. 
    
  41. import com.jme.util.export.InputCapsule;
    
  42. import com.jme.util.export.JMEExporter;
    
  43. import com.jme.util.export.JMEImporter;
    
  44. import com.jme.util.export.OutputCapsule;
    
  45. import com.jme.util.export.Savable;
    
  46. 
    
  47. /*
    
  48.  * -- Added *Local methods to cut down on object creation - JS
    
  49.  */
    
  50. 
    
  51. /**
    
  52.  * <code>Vector3f</code> defines a Vector for a three float value tuple.
    
  53.  * <code>Vector3f</code> can represent any three dimensional value, such as a
    
  54.  * vertex, a normal, etc. Utility methods are also included to aid in
    
  55.  * mathematical calculations.<br/>
    
  56.  * 3维向量类
    
  57.  * 
    
  58.  * @author Mark Powell
    
  59.  * @author Joshua Slack
    
  60.  */
    
  61. public class Vector3f implements Externalizable, Savable, Cloneable {
    
  62.     private static final Logger logger = Logger.getLogger(Vector3f.class
    
  63.             .getName());
    
  64. 
    
  65.     private static final long serialVersionUID = 1L;
    
  66. 
    
  67.     public final static Vector3f ZERO = new Vector3f(0, 0, 0);
    
  68. 
    
  69.     public final static Vector3f UNIT_X = new Vector3f(1, 0, 0);
    
  70.     public final static Vector3f UNIT_Y = new Vector3f(0, 1, 0);
    
  71.     public final static Vector3f UNIT_Z = new Vector3f(0, 0, 1);
    
  72.     public final static Vector3f UNIT_XYZ = new Vector3f(1, 1, 1);
    
  73. 
    
  74.     /**
    
  75.      * the x value of the vector.
    
  76.      */
    
  77.     public float x;
    
  78. 
    
  79.     /**
    
  80.      * the y value of the vector.
    
  81.      */
    
  82.     public float y;
    
  83. 
    
  84.     /**
    
  85.      * the z value of the vector.
    
  86.      */
    
  87.     public float z;
    
  88. 
    
  89.     /**
    
  90.      * Constructor instantiates a new <code>Vector3f</code> with default values
    
  91.      * of (0,0,0).
    
  92.      * 
    
  93.      */
    
  94.     public Vector3f() {
    
  95.         x = y = z = 0;
    
  96.     }
    
  97. 
    
  98.     /**
    
  99.      * Constructor instantiates a new <code>Vector3f</code> with provides
    
  100.      * values.
    
  101.      * 
    
  102.      * @param x
    
  103.      *            the x value of the vector.
    
  104.      * @param y
    
  105.      *            the y value of the vector.
    
  106.      * @param z
    
  107.      *            the z value of the vector.
    
  108.      */
    
  109.     public Vector3f(float x, float y, float z) {
    
  110.         this.x = x;
    
  111.         this.y = y;
    
  112.         this.z = z;
    
  113.     }
    
  114. 
    
  115.     /**
    
  116.      * Constructor instantiates a new <code>Vector3f</code> that is a copy of
    
  117.      * the provided vector
    
  118.      * 
    
  119.      * @param copy
    
  120.      *            The Vector3f to copy
    
  121.      */
    
  122.     public Vector3f(Vector3f copy) {
    
  123.         this.set(copy);
    
  124.     }
    
  125. 
    
  126.     /**
    
  127.      * <code>set</code> sets the x,y,z values of the vector based on passed
    
  128.      * parameters.
    
  129.      * 
    
  130.      * @param x
    
  131.      *            the x value of the vector.
    
  132.      * @param y
    
  133.      *            the y value of the vector.
    
  134.      * @param z
    
  135.      *            the z value of the vector.
    
  136.      * @return this vector
    
  137.      */
    
  138.     public Vector3f set(float x, float y, float z) {
    
  139.         this.x = x;
    
  140.         this.y = y;
    
  141.         this.z = z;
    
  142.         return this;
    
  143.     }
    
  144. 
    
  145.     /**
    
  146.      * <code>set</code> sets the x,y,z values of the vector by copying the
    
  147.      * supplied vector.
    
  148.      * 
    
  149.      * @param vect
    
  150.      *            the vector to copy.
    
  151.      * @return this vector
    
  152.      */
    
  153.     public Vector3f set(Vector3f vect) {
    
  154.         this.x = vect.x;
    
  155.         this.y = vect.y;
    
  156.         this.z = vect.z;
    
  157.         return this;
    
  158.     }
    
  159. 
    
  160.     /**
    
  161.      * 
    
  162.      * <code>add</code> adds a provided vector to this vector creating a
    
  163.      * resultant vector which is returned. If the provided vector is null, null
    
  164.      * is returned.<br/>
    
  165.      * 向量加法(不改变自身和参数)
    
  166.      * 
    
  167.      * Neither 'this' nor 'vec' are modified.
    
  168.      * 
    
  169.      * @param vec
    
  170.      *            the vector to add to this.
    
  171.      * @return the resultant vector.
    
  172.      */
    
  173.     public Vector3f add(Vector3f vec) {
    
  174.         if (null == vec) {
    
  175.             logger.warning("Provided vector is null, null returned.");
    
  176.             return null;
    
  177.         }
    
  178.         return new Vector3f(x + vec.x, y + vec.y, z + vec.z);
    
  179.     }
    
  180. 
    
  181.     /**
    
  182.      * 
    
  183.      * <code>add</code> adds the values of a provided vector storing the values
    
  184.      * in the supplied vector.<br/>
    
  185.      * 向量加法
    
  186.      * 
    
  187.      * @param vec
    
  188.      *            the vector to add to this
    
  189.      * @param result
    
  190.      *            the vector to store the result in
    
  191.      * @return result returns the supplied result vector.
    
  192.      */
    
  193.     public Vector3f add(Vector3f vec, Vector3f result) {
    
  194.         result.x = x + vec.x;
    
  195.         result.y = y + vec.y;
    
  196.         result.z = z + vec.z;
    
  197.         return result;
    
  198.     }
    
  199. 
    
  200.     /**
    
  201.      * <code>addLocal</code> adds a provided vector to this vector internally,
    
  202.      * and returns a handle to this vector for easy chaining of calls. If the
    
  203.      * provided vector is null, null is returned.<br/>
    
  204.      * 向量加法(自加)
    
  205.      * 
    
  206.      * @param vec
    
  207.      *            the vector to add to this vector.
    
  208.      * @return this
    
  209.      */
    
  210.     public Vector3f addLocal(Vector3f vec) {
    
  211.         if (null == vec) {
    
  212.             logger.warning("Provided vector is null, null returned.");
    
  213.             return null;
    
  214.         }
    
  215.         x += vec.x;
    
  216.         y += vec.y;
    
  217.         z += vec.z;
    
  218.         return this;
    
  219.     }
    
  220. 
    
  221.     /**
    
  222.      * 
    
  223.      * <code>add</code> adds the provided values to this vector, creating a new
    
  224.      * vector that is then returned.<br/>
    
  225.      * 向量加法
    
  226.      * 
    
  227.      * @param addX
    
  228.      *            the x value to add.
    
  229.      * @param addY
    
  230.      *            the y value to add.
    
  231.      * @param addZ
    
  232.      *            the z value to add.
    
  233.      * @return the result vector.
    
  234.      */
    
  235.     public Vector3f add(float addX, float addY, float addZ) {
    
  236.         return new Vector3f(x + addX, y + addY, z + addZ);
    
  237.     }
    
  238. 
    
  239.     /**
    
  240.      * <code>addLocal</code> adds the provided values to this vector internally,
    
  241.      * and returns a handle to this vector for easy chaining of calls.<br/>
    
  242.      * 向量加法(自加)
    
  243.      * 
    
  244.      * @param addX
    
  245.      *            value to add to x
    
  246.      * @param addY
    
  247.      *            value to add to y
    
  248.      * @param addZ
    
  249.      *            value to add to z
    
  250.      * @return this
    
  251.      */
    
  252.     public Vector3f addLocal(float addX, float addY, float addZ) {
    
  253.         x += addX;
    
  254.         y += addY;
    
  255.         z += addZ;
    
  256.         return this;
    
  257.     }
    
  258. 
    
  259.     /**
    
  260.      * 
    
  261.      * <code>scaleAdd</code> multiplies this vector by a scalar then adds the
    
  262.      * given Vector3f.<br/>
    
  263.      * 向量加乘(先乘一个标量,再加一个向量)
    
  264.      * 
    
  265.      * @param scalar
    
  266.      *            the value to multiply this vector by.
    
  267.      * @param add
    
  268.      *            the value to add
    
  269.      */
    
  270.     public void scaleAdd(float scalar, Vector3f add) {
    
  271.         x = x * scalar + add.x;
    
  272.         y = y * scalar + add.y;
    
  273.         z = z * scalar + add.z;
    
  274.     }
    
  275. 
    
  276.     /**
    
  277.      * 
    
  278.      * <code>scaleAdd</code> multiplies the given vector by a scalar then adds
    
  279.      * the given vector.<br/>
    
  280.      * 向量加乘(将mult乘以标量scalar,再加上向量add,返回this)
    
  281.      * 
    
  282.      * @param scalar
    
  283.      *            the value to multiply this vector by.
    
  284.      * @param mult
    
  285.      *            the value to multiply the scalar by
    
  286.      * @param add
    
  287.      *            the value to add
    
  288.      */
    
  289.     public void scaleAdd(float scalar, Vector3f mult, Vector3f add) {
    
  290.         this.x = mult.x * scalar + add.x;
    
  291.         this.y = mult.y * scalar + add.y;
    
  292.         this.z = mult.z * scalar + add.z;
    
  293.     }
    
  294. 
    
  295.     /**
    
  296.      * 
    
  297.      * <code>dot</code> calculates the dot product of this vector with a
    
  298.      * provided vector. If the provided vector is null, 0 is returned.<br/>
    
  299.      * 向量点乘
    
  300.      * 
    
  301.      * @param vec
    
  302.      *            the vector to dot with this vector.
    
  303.      * @return the resultant dot product of this vector and a given vector.
    
  304.      */
    
  305.     public float dot(Vector3f vec) {
    
  306.         if (null == vec) {
    
  307.             logger.warning("Provided vector is null, 0 returned.");
    
  308.             return 0;
    
  309.         }
    
  310.         return x * vec.x + y * vec.y + z * vec.z;
    
  311.     }
    
  312. 
    
  313.     /**
    
  314.      * Returns a new vector which is the cross product of this vector with the
    
  315.      * specified vector.<br/>
    
  316.      * 叉乘(不改变自身和参数)
    
  317.      * <P>
    
  318.      * Neither 'this' nor v are modified. The starting value of 'result'
    
  319.      * </P>
    
  320.      * 
    
  321.      * @param v
    
  322.      *            the vector to take the cross product of with this.
    
  323.      * @return the cross product vector.
    
  324.      */
    
  325.     public Vector3f cross(Vector3f v) {
    
  326.         return cross(v, null);
    
  327.     }
    
  328. 
    
  329.     /**
    
  330.      * <code>cross</code> calculates the cross product of this vector with a
    
  331.      * parameter vector v. The result is stored in <code>result</code><br/>
    
  332.      * 叉乘(this与v叉乘,结果存入result中。不改变自身和参数)
    
  333.      * <P>
    
  334.      * Neither 'this' nor v are modified. The starting value of 'result' (if
    
  335.      * any) is ignored.
    
  336.      * </P>
    
  337.      * 
    
  338.      * @param v
    
  339.      *            the vector to take the cross product of with this.
    
  340.      * @param result
    
  341.      *            the vector to store the cross product result.
    
  342.      * @return result, after recieving the cross product vector.
    
  343.      */
    
  344.     public Vector3f cross(Vector3f v, Vector3f result) {
    
  345.         return cross(v.x, v.y, v.z, result);
    
  346.     }
    
  347. 
    
  348.     /**
    
  349.      * <code>cross</code> calculates the cross product of this vector with a
    
  350.      * Vector comprised of the specified other* elements. The result is stored
    
  351.      * in <code>result</code>, without modifying either 'this' or the 'other*'
    
  352.      * values.<br/>
    
  353.      * 叉乘(this与参数叉乘,结果存在参数result中)
    
  354.      * 
    
  355.      * @param otherX
    
  356.      *            x component of the vector to take the cross product of with
    
  357.      *            this.
    
  358.      * @param otherY
    
  359.      *            y component of the vector to take the cross product of with
    
  360.      *            this.
    
  361.      * @param otherZ
    
  362.      *            z component of the vector to take the cross product of with
    
  363.      *            this.
    
  364.      * @param result
    
  365.      *            the vector to store the cross product result.
    
  366.      * @return result, after recieving the cross product vector.
    
  367.      */
    
  368.     public Vector3f cross(float otherX, float otherY, float otherZ,
    
  369.             Vector3f result) {
    
  370.         if (result == null)
    
  371.             result = new Vector3f();
    
  372.         float resX = ((y * otherZ) - (z * otherY));
    
  373.         float resY = ((z * otherX) - (x * otherZ));
    
  374.         float resZ = ((x * otherY) - (y * otherX));
    
  375.         result.set(resX, resY, resZ);
    
  376.         return result;
    
  377.     }
    
  378. 
    
  379.     /**
    
  380.      * <code>crossLocal</code> calculates the cross product of this vector with
    
  381.      * a parameter vector v.<br/>
    
  382.      * 自身叉乘(this与参数叉乘,结果存入自身)
    
  383.      * 
    
  384.      * @param v
    
  385.      *            the vector to take the cross product of with this.
    
  386.      * @return this.
    
  387.      */
    
  388.     public Vector3f crossLocal(Vector3f v) {
    
  389.         return crossLocal(v.x, v.y, v.z);
    
  390.     }
    
  391. 
    
  392.     /**
    
  393.      * <code>crossLocal</code> calculates the cross product of this vector with
    
  394.      * a parameter vector v.<br/>
    
  395.      * 自身叉乘(this与参数叉乘,结果存入自身)
    
  396.      * 
    
  397.      * @param otherX
    
  398.      *            x component of the vector to take the cross product of with
    
  399.      *            this.
    
  400.      * @param otherY
    
  401.      *            y component of the vector to take the cross product of with
    
  402.      *            this.
    
  403.      * @param otherZ
    
  404.      *            z component of the vector to take the cross product of with
    
  405.      *            this.
    
  406.      * @return this.
    
  407.      */
    
  408.     public Vector3f crossLocal(float otherX, float otherY, float otherZ) {
    
  409.         float tempx = (y * otherZ) - (z * otherY);
    
  410.         float tempy = (z * otherX) - (x * otherZ);
    
  411.         z = (x * otherY) - (y * otherX);
    
  412.         x = tempx;
    
  413.         y = tempy;
    
  414.         return this;
    
  415.     }
    
  416. 
    
  417.     /**
    
  418.      * <code>length</code> calculates the magnitude of this vector.<br/>
    
  419.      * 向量长度
    
  420.      * 
    
  421.      * @return the length or magnitude of the vector.
    
  422.      */
    
  423.     public float length() {
    
  424.         return FastMath.sqrt(lengthSquared());
    
  425.     }
    
  426. 
    
  427.     /**
    
  428.      * <code>lengthSquared</code> calculates the squared value of the magnitude
    
  429.      * of the vector.<br/>
    
  430.      * 向量长度平方
    
  431.      * 
    
  432.      * @return the magnitude squared of the vector.
    
  433.      */
    
  434.     public float lengthSquared() {
    
  435.         return x * x + y * y + z * z;
    
  436.     }
    
  437. 
    
  438.     /**
    
  439.      * <code>distanceSquared</code> calculates the distance squared between this
    
  440.      * vector and vector v.<br/>
    
  441.      * 向量this与参赛v间的距离平方
    
  442.      * 
    
  443.      * @param v
    
  444.      *            the second vector to determine the distance squared.
    
  445.      * @return the distance squared between the two vectors.
    
  446.      */
    
  447.     public float distanceSquared(Vector3f v) {
    
  448.         double dx = x - v.x;
    
  449.         double dy = y - v.y;
    
  450.         double dz = z - v.z;
    
  451.         return (float) (dx * dx + dy * dy + dz * dz);
    
  452.     }
    
  453. 
    
  454.     /**
    
  455.      * <code>distance</code> calculates the distance between this vector and
    
  456.      * vector v.<br/>
    
  457.      * 向量this与参赛v间的距离
    
  458.      * 
    
  459.      * @param v
    
  460.      *            the second vector to determine the distance.
    
  461.      * @return the distance between the two vectors.
    
  462.      */
    
  463.     public float distance(Vector3f v) {
    
  464.         return FastMath.sqrt(distanceSquared(v));
    
  465.     }
    
  466. 
    
  467.     /**
    
  468.      * <code>mult</code> multiplies this vector by a scalar. The resultant
    
  469.      * vector is returned. "this" is not modified.<br/>
    
  470.      * 向量标量乘
    
  471.      * 
    
  472.      * @param scalar
    
  473.      *            the value to multiply this vector by.
    
  474.      * @return the new vector.
    
  475.      */
    
  476.     public Vector3f mult(float scalar) {
    
  477.         return new Vector3f(x * scalar, y * scalar, z * scalar);
    
  478.     }
    
  479. 
    
  480.     /**
    
  481.      * 
    
  482.      * <code>mult</code> multiplies this vector by a scalar. The resultant
    
  483.      * vector is supplied as the second parameter and returned. "this" is not
    
  484.      * modified.<br/>
    
  485.      * 向量标量乘,结果存入product。
    
  486.      * 
    
  487.      * @param scalar
    
  488.      *            the scalar to multiply this vector by.
    
  489.      * @param product
    
  490.      *            the product to store the result in.
    
  491.      * @return product
    
  492.      */
    
  493.     public Vector3f mult(float scalar, Vector3f product) {
    
  494.         if (null == product) {
    
  495.             product = new Vector3f();
    
  496.         }
    
  497. 
    
  498.         product.x = x * scalar;
    
  499.         product.y = y * scalar;
    
  500.         product.z = z * scalar;
    
  501.         return product;
    
  502.     }
    
  503. 
    
  504.     /**
    
  505.      * <code>multLocal</code> multiplies this vector by a scalar internally, and
    
  506.      * returns a handle to this vector for easy chaining of calls.<br/>
    
  507.      * 向量标量乘this
    
  508.      * 
    
  509.      * @param scalar
    
  510.      *            the value to multiply this vector by.
    
  511.      * @return this
    
  512.      */
    
  513.     public Vector3f multLocal(float scalar) {
    
  514.         x *= scalar;
    
  515.         y *= scalar;
    
  516.         z *= scalar;
    
  517.         return this;
    
  518.     }
    
  519. 
    
  520.     /**
    
  521.      * <code>multLocal</code> multiplies a provided vector to this vector
    
  522.      * internally, and returns a handle to this vector for easy chaining of
    
  523.      * calls. If the provided vector is null, null is returned. The provided
    
  524.      * 'vec' is not modified.<br/>
    
  525.      * 向量标量乘一个向量(对应的x、y、z分量分别相乘),结果改变this
    
  526.      * 
    
  527.      * @param vec
    
  528.      *            the vector to mult to this vector.
    
  529. 
    
      
    
    
      
    分享到:
    评论

相关推荐

    Vector3——简单的3D向量类

    vector3 类,实现的功能 1、重载赋值运算符“=” 2、重载“==”和“!=”操作符 3、置为零向量 4、重载一元运算符“-” 5、重载二元预算法“+”“-” 6、标量的乘除法 7、重载自反运算符 8、向量单位化 9、向量的...

    pvectorjs:基于Processing PVector类的具有可链接方法JavaScript 2D3D向量类,用于常见向量操作,该方法具有可链接的方法

    PVectorJS 基于Processing PVector类的具有可链接方法JavaScript 2D / 3D向量类,用于常见的向量操作安装Node.js / Browserify npm install pvectorjs --save const PVector = require ( 'pvectorjs' )const vec = ...

    C#向量类定义和向量四则运算

    向量类的定义通常包括坐标(如x、y、z)以及各种基本操作,例如加法、减法、标量乘法(点乘)和向量乘法(叉乘)。以下是一个详细的关于C#中向量类定义和向量四则运算的阐述: **向量类定义** 一个简单的向量类...

    3D数学基础:图形与游戏开发(英文原版)

    第6章 3D向量类 …… 第7章 矩阵 第8章 矩阵和线性变换 第9章 矩阵的更多知识 第10章 3D中的方位与角位移 第11章 C++实现 第12章 几何图元 第13章 几何检测 第14章 三角网络 第15章 图形数学 第16章 可见性检测 第17...

    j2me 2D及3D向量几何图形学

    在Java 2 Micro Edition (J2ME)平台上,2D和3D向量几何图形学是构建游戏、应用程序和可视化工具的关键技术。向量几何图形学涉及到数学中的向量概念,以及如何在2D和3D空间中使用它们来表示位置、方向、速度和力。...

    3D数学基础 图形与游戏开发

    第6章 3D向量类 …… 第7章 矩阵 第8章 矩阵和线性变换 第9章 矩阵的更多知识 第10章 3D中的方位与角位移 第11章 C++实现 第12章 几何图元 第13章 几何检测 第14章 三角网络 第15章 图形数学 第16章 可见性检测 第17...

    C++向量类的实现,在使用的时候可以直接调用

    在C++编程中,向量类的实现是一个常见的任务,特别是在处理图形学、物理模拟或者游戏开发等场景。向量可以表示空间中的位置、速度、加速度等多种概念,因此理解和自定义向量类是非常重要的。这里我们将深入探讨提供...

    pengzhuangjiance.zip_3D 碰撞_3d碰撞检测

    4. Tvector.cpp 和 Tvector.h:定义了3D向量类,向量在3D空间中广泛用于表示位置、速度、方向和法线等。碰撞检测中,向量常常用来计算距离、方向和速度差,以判断两个物体是否相交。 5. Tray.cpp 和 Tray.h:可能...

    3dmath 3D数学类

    Vector3d 类:简单的3D向量类 RotationMatrix 类:实现了一个简单的3*3矩阵,仅用作旋转;矩阵假设为正交的,在变换时指定方向 Matrix4_3 类:实现4*3转换矩阵,能够表达任何3D仿射变换 EulerAngles 类:该类用于表示...

    VC++ 9.0 向量类

    在VC++ 9.0环境下,向量类的实现是一个重要的编程工具,特别是在3D图形学、物理模拟和游戏开发等领域。向量是数学中一个非常基础且实用的概念,它代表了一个具有大小和方向的量。在编程中,向量类通常用来表示二维或...

    vector3:SIMD 3D 向量 C++ 实现

    这是一个使用指令实现数学 3D 向量类的简单 C++ 库。 它基于。 例子 测试.cpp # include # include " vector3.h " int main () { Vector3 a ( 1 , 1 , 1 ); Vector3 b ( 2 , 0 , - 1 ); std::cout &lt;&lt; " a...

    unity3D中的向量几何

    Unity3D 中的向量几何 Unity3D 中的向量几何是一种广泛应用于游戏编程中的数学工具。游戏程序员可以使用向量几何来模拟物理现象和基本的 AI。向量几何可以帮助游戏程序员更好地理解游戏中的坐标系和运动物体的轨迹...

    k-近邻点估计点云法向量,及3D-pointcloud

    点云法向量是3D空间中描述表面方向的关键元素,它表示了点云中每个点表面局部的正向。在计算机视觉、机器人导航、3D建模等领域,理解和计算点云的法向量至关重要。k-近邻点估计法(k-Nearest Neighbors, k-NN)是一...

    Unity3D教程:向量1

    例如,以下代码创建了一个位于原点上方1单位的3D向量: ```csharp var aPosition : Vector3; aPosition = new Vector3(0, 1, 0); ``` 或者,你可以直接通过成员变量设置各个分量: ```csharp var aPosition : ...

    3D图形库向量函数库示例源代码

    在3D图形编程中,向量函数库是至关重要的组成部分,它提供了处理三维空间中向量的基本操作。向量不仅用于表示位置,还用于描述方向、速度和力等概念。本示例源代码集中展示了几个关键的向量操作,包括向量的加法、...

    vc-stl.rar_STL_VC STL_stl 坐标_vc CAD STL_vc++读取 显示

    - `Vector3d.cpp`:可能实现了3D向量类,用于表示顶点和法线。 - `Matrix33.cpp`:可能包含了3x3矩阵类,用于进行3D空间中的变换操作。 - `AxisSystem.cpp`:可能包含了轴系的绘制代码,用于显示坐标轴。 - `...

    C++ 二维 三维 坐标(向量)类 的设计代码下载(2D,3D,点类)

    如果有疏忽或错误的地方...这里一共设计了两个类:Location,Point,分别代表二维和三维坐标(向量)类。 对类的+ - * / &gt;&gt; 都进行了重载。 大部分函数使用及功能都有详细说明,注释内容说明的均是上个函数和语句的功能

    (广东省科学技术职业学院3D教程)向量叉积

    在3D图形编程和游戏开发中,向量是至关重要的概念,它们被广泛用于表示位置、速度、方向等。Visual C++ 和 DirectX9 是开发者常用的技术栈,用于创建高性能的3D应用程序。在这个3D教程中,我们将深入探讨向量叉积这...

    Unity3D实现用向量叉乘判断转向

    [Unity游戏开发]向量在游戏开发中的应用(三)博客中的案例源码。 本Demo使用的的开发工具是Unity5.0.1f1和VS2013,建议下载源码后用Unity5.0.1f1或者更高的版本打开。 本源码可以配合Sheh伟伟的博客来学习。

    3D 数学库-矩阵 向量 四元数

    在计算机科学领域,尤其是计算机图形学中,3D数学库是不可或缺的一部分,它涉及到的核心概念主要包括矩阵、向量和四元数。这些概念是构建3D世界、进行几何变换和动画制作的基础。下面将详细解释这三个核心概念及其在...

Global site tag (gtag.js) - Google Analytics