当前位置: 首页>>代码示例>>C++>>正文


C++ vector3df::dotProduct方法代码示例

本文整理汇总了C++中core::vector3df::dotProduct方法的典型用法代码示例。如果您正苦于以下问题:C++ vector3df::dotProduct方法的具体用法?C++ vector3df::dotProduct怎么用?C++ vector3df::dotProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core::vector3df的用法示例。


在下文中一共展示了vector3df::dotProduct方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getReflected

//██████████████████████████████████████████████████████████████████████████████████
// reflection with normal  
core::vector3df getReflected( core::vector3df vector, core::vector3df normal ) { 
	f32 length = (f32)vector.getLength();
	vector.normalize();
	normal.normalize(); 
	
	return (vector - normal * 2.0f * (vector.dotProduct( normal))) * length; 
}
开发者ID:xhlwrb,项目名称:MeshlessDeformations,代码行数:9,代码来源:Globals.cpp

示例2: applyVertexShadows

void CBillboardGroupSceneNode::applyVertexShadows( const core::vector3df& lightDir, f32 intensity, f32 ambient )
{
    for ( s32 i=0; i<Billboards.size(); i++ )
    {
        core::vector3df normal = Billboards[i].Position;
        
        normal.normalize();
        
        f32 light = -lightDir.dotProduct(normal)*intensity + ambient;
        
        if ( light < 0 )
            light = 0;
        
        if ( light > 1 )
            light = 1;
        
        video::SColor color;
        
        color.setRed( (u8)(Billboards[i].Color.getRed() * light) );
        color.setGreen( (u8)(Billboards[i].Color.getGreen() * light) );
        color.setBlue( (u8)(Billboards[i].Color.getBlue() * light) );
        color.setAlpha( Billboards[i].Color.getAlpha() );
        
        for ( s32 j=0; j<4; j++ )
        {
            MeshBuffer.Vertices[i*4+j].Color = color;
        }
    }
}
开发者ID:SevenGameMaker,项目名称:CobbleStones,代码行数:29,代码来源:CBillboardGroupSceneNode.cpp

示例3: Write

/*------------------------------------------------------------------------------
|
|                           PROCEDURE LAMBERTUNIV
|
|  This PROCEDURE solves the Lambert problem for orbit determination and returns
|    the velocity vectors at each of two given position vectors.  The solution
|    uses Universal Variables for calculation and a bissection technique for
|    updating psi.
|
|  Algorithm     : Setting the initial bounds:
|                  Using -8Pi and 4Pi2 will allow single rev solutions
|                  Using -4Pi2 and 8Pi2 will allow multi-rev solutions
|                  The farther apart the initial guess, the more iterations
|                    because of the iteration
|                  Inner loop is for special cases. Must be sure to exit both!
|
|  Author        : David Vallado                  303-344-6037    1 Mar 2001
|
|  Inputs          Description                    Range / Units
|    R1          - IJK Position vector 1          ER
|    R2          - IJK Position vector 2          ER
|    DM          - direction of motion            'L','S'
|    DtTU        - Time between R1 and R2         TU
|
|  OutPuts       :
|    V1          - IJK Velocity vector            ER / TU
|    V2          - IJK Velocity vector            ER / TU
|    Error       - Error flag                     'ok', ...
|
|  Locals        :
|    VarA        - Variable of the iteration,
|                  NOT the semi or axis!
|    Y           - Area between position vectors
|    Upper       - Upper bound for Z
|    Lower       - Lower bound for Z
|    CosDeltaNu  - Cosine of true anomaly change  rad
|    F           - f expression
|    G           - g expression
|    GDot        - g DOT expression
|    XOld        - Old Universal Variable X
|    XOldCubed   - XOld cubed
|    ZOld        - Old value of z
|    ZNew        - New value of z
|    C2New       - C2(z) FUNCTION
|    C3New       - C3(z) FUNCTION
|    TimeNew     - New time                       TU
|    Small       - Tolerance for roundoff errors
|    i, j        - index
|
|  Coupling
|    MAG         - Magnitude of a vector
|    DOT         - DOT product of two vectors
|    FINDC2C3    - Find C2 and C3 functions
|
|  References    :
|    Vallado       2001, 459-464, Alg 55, Ex 7-5
|
-----------------------------------------------------------------------------*/
void LambertUniv
(
 core::vector3df Ro, core::vector3df R, char Dm, char OverRev, f64 DtTU,
 core::vector3df& Vo, core::vector3df& V, char* Error)
{
	const f64 TwoPi   = 2.0 * core::PI64;
	const f64 Small   = 0.0000001;
	const u32 NumIter = 40;

	u32 Loops, i, YNegKtr;
	f64 VarA, Y, Upper, Lower, CosDeltaNu, F, G, GDot, XOld, XOldCubed, FDot,
		PsiOld, PsiNew, C2New, C3New, dtNew;

	/* --------------------  Initialize values   -------------------- */
	strcpy(Error, "ok");
	PsiNew = 0.0;
	Vo = core::vector3df(0,0,0);
	V = core::vector3df(0,0,0);

	CosDeltaNu = Ro.dotProduct(R) / (Ro.getLength() * R.getLength());
	if (Dm == 'L')
		VarA = -sqrt(Ro.getLength() * R.getLength() * (1.0 + CosDeltaNu));
	else
		VarA =  sqrt(Ro.getLength() * R.getLength() * (1.0 + CosDeltaNu));

	/* ----------------  Form Initial guesses   --------------------- */
	PsiOld = 0.0;
	PsiNew = 0.0;
	XOld   = 0.0;
	C2New  = 0.5;
	C3New  = 1.0 / 6.0;

	/* -------- Set up initial bounds for the bissection ------------ */
	if (OverRev == 'N')
	{
		Upper = TwoPi * TwoPi;
		Lower = -4.0 * TwoPi;
	}
	else
	{
		Upper = -0.001 + 4.0 * TwoPi * TwoPi; // at 4, not alw work, 2.0, makes
		Lower =  0.001+TwoPi*TwoPi;           // orbit bigger, how about 2 revs??xx
//.........这里部分代码省略.........
开发者ID:oygx210,项目名称:slingshot,代码行数:101,代码来源:lambert2.cpp

示例4: Battin

/*------------------------------------------------------------------------------
|
|                           PROCEDURE LAMBERBATTIN
|
|  This PROCEDURE solves Lambert's problem using Battins method. The method is
|    developed in Battin (1987).
|
|  Author        : David Vallado                  303-344-6037    1 Mar 2001
|
|  Inputs          Description                    Range / Units
|    Ro          - IJK Position vector 1          ER
|    R           - IJK Position vector 2          ER
|    DM          - direction of motion            'L','S'
|    DtTU        - Time between R1 and R2         TU
|
|  OutPuts       :
|    Vo          - IJK Velocity vector            ER / TU
|    V           - IJK Velocity vector            ER / TU
|    Error       - Error flag                     'ok',...
|
|  Locals        :
|    i           - Index
|    Loops       -
|    u           -
|    b           -
|    Sinv        -
|    Cosv        -
|    rp          -
|    x           -
|    xn          -
|    y           -
|    l           -
|    m           -
|    CosDeltaNu  -
|    SinDeltaNu  -
|    DNu         -
|    a           -
|    Tan2w       -
|    RoR         -
|    h1          -
|    h2          -
|    Tempx       -
|    eps         -
|    denom       -
|    chord       -
|    k2          -
|    s           -
|    f           -
|    g           -
|    fDot        -
|    am          -
|    ae          -
|    be          -
|    tm          -
|    gDot        -
|    arg1        -
|    arg2        -
|    tc          -
|    AlpE        -
|    BetE        -
|    AlpH        -
|    BetH        -
|    DE          -
|    DH          -
|
|  Coupling      :
|    ARCSIN      - Arc sine FUNCTION
|    ARCCOS      - Arc cosine FUNCTION
|    MAG         - Magnitude of a vector
|    ARCSINH     - Inverse hyperbolic sine
|    ARCCOSH     - Inverse hyperbolic cosine
|    SINH        - Hyperbolic sine
|    POWER       - Raise a base to a POWER
|    ATAN2       - Arc tangent FUNCTION that resolves quadrants
|
|  References    :
|    Vallado       2001, 464-467, Ex 7-5
|
-----------------------------------------------------------------------------*/
void LambertBattin
(
 core::vector3df Ro, core::vector3df R, char dm, char OverRev, f64 DtTU,
 core::vector3df* Vo, core::vector3df* V, char* Error
 )
{
	const f64 Small = 0.000001;

	core::vector3df RCrossR;
	s32   i, Loops;
	f64   u, b, Sinv,Cosv, rp, x, xn, y, L, m, CosDeltaNu, SinDeltaNu,DNu, a,
		tan2w, RoR, h1, h2, Tempx, eps, Denom, chord, k2, s, f, g, FDot, am,
		ae, be, tm, GDot, arg1, arg2, tc, AlpE, BetE, AlpH, BetH, DE, DH;

	strcpy(Error, "ok");
	CosDeltaNu = Ro.dotProduct(R) / (Ro.getLength() * R.getLength());
	RCrossR    = Ro.crossProduct(R);
	SinDeltaNu = RCrossR.getLength() / (Ro.getLength() * R.getLength());
	DNu        = atan2(SinDeltaNu, CosDeltaNu);

	RoR   = R.getLength() / Ro.getLength();
//.........这里部分代码省略.........
开发者ID:oygx210,项目名称:slingshot,代码行数:101,代码来源:lambert2.cpp

示例5: LambertCompute

/** Computes the delta-v's required to go from r0,v0 to rf,vf.
* @return Total delta-v (magnitude) required.
* @param dt Time of flight
* @param r0 Initial position vector.
* @param v0 Initial velocity vector.
* @param rf Desired final position vector.
* @param vf Desired final velocity vector.
* //pointers to return results
* @param deltaV0 computed Initial delta-V.
* @param deltaV1 computed Final delta-V.
* @param totalV0 computed Initial total-V.
* @param totalV0 computed Final total-V.
*/
void LambertCompute(f64 GM, 
                    core::vector3df r0,
                    core::vector3df v0,
                    core::vector3df rf,
                    core::vector3df vf, 
                    f64 dt,
                    core::vector3df* deltaV0,
                    core::vector3df* deltaV1,
                    core::vector3df* totalV0,
                    core::vector3df* totalV1)
{
    s = 0.0;
    c = 0.0;
    aflag = false;
    bflag = false;
    debug_print=true;

    f64 tp = 0.0;
    f64 magr0 = r0.getLength();
    f64 magrf = rf.getLength();
    //GM is expected in km^3/s^2
    mu = GM / 1000000000.0;
    //time of flight expected in seconds
    dt *= 86400;
    tof = dt;

    core::vector3df dr = r0 - (rf);
    c = dr.getLength();
    s = (magr0 + magrf + c) / 2.0;
    f64 amin = s / 2.0;
    
    if(debug_print)
        printf("amin = %.9E\n", amin);
    
    f64 dtheta = acos(r0.dotProduct(rf) / (magr0 * magrf));

    //dtheta = 2.0 * core::PI64 - dtheta;

    if(debug_print)
        printf("dtheta = %.9E\n", dtheta);
    
    if (dtheta < core::PI64)
    {
        tp = sqrt(2.0 / (mu)) * (pow(s, 1.5) - pow(s - c, 1.5)) / 3.0;
    }
    if (dtheta > core::PI64)
    {
        tp = sqrt(2.0 / (mu)) * (pow(s, 1.5) + pow(s - c, 1.5)) / 3.0;
        bflag = true;
    }

    if(debug_print)
        printf("tp = %.9f\n", tp);

    f64 betam = getbeta(amin);
    f64 tm = getdt(amin, core::PI64, betam);

    if(debug_print)
        printf("tm = %.9E\n", tm);

    if (dtheta == core::PI64)
    {
        printf(" dtheta = 180.0. Do a Hohmann\n");
        return;
    }

    f64 ahigh = 1000.0 * amin;
    f64 npts = 3000.0;
    
    if(debug_print)
        printf("dt = %.9E seconds\n", dt);

    if(debug_print)
        printf("************************************************\n");

    if (dt < tp)
    {
        printf(" No elliptical path possible \n");
        return;
    }

    if (dt > tm)
    {
        aflag = true;
    }

    f64 fm = evaluate(amin);
//.........这里部分代码省略.........
开发者ID:oygx210,项目名称:slingshot,代码行数:101,代码来源:Lambert_Jat.cpp


注:本文中的core::vector3df::dotProduct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。