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


C# Vector.x方法代码示例

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


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

示例1: LineIntersects2dObject

    public static Storage LineIntersects2dObject(Vector position, Vector feeler,
										Vector lineCoordA, Vector lineCoordB,
										double distance, Vector pt)
    {
        Storage tmp = new Storage();

        double top = ((position.y() - lineCoordA.y())*(lineCoordB.x() - lineCoordA.x())) -
                     ((position.x() - lineCoordA.x())* (lineCoordB.y()-lineCoordA.y()));
        double bot = ((feeler.x()-position.x())*(lineCoordB.y()-lineCoordA.y())) -
                     ((feeler.y()-position.y())*(lineCoordB.x()-lineCoordA.x()));

        double topTwo = ((position.y() - lineCoordA.y())*(feeler.x() - position.x())) -
                     ((position.x() - lineCoordA.x())* (feeler.y()-position.y()));
        double botTwo = bot;

        if(bot == 0)tmp.wasItTrue = false;
        double r = top / bot;
        double t = topTwo / botTwo;
        if( (r > 0) && (r < 1) && (t > 0) && (t < 1)){
            Vector temp =feeler - position;
            tmp.dist = Mathf.Sqrt((float)temp.lengthSquared());
            pt = position + (temp * r);
            tmp.wasItTrue = true;
        }else {
            tmp.dist = 0;
            tmp.wasItTrue = false;
        }
        return tmp;
    }
开发者ID:WildernessBob,项目名称:Game,代码行数:29,代码来源:MathExtension.cs

示例2: cross

 public static Vector cross( Vector v1, Vector v2 )
 {
     return new Vector(
     v1.y()*v2.z() - v1.z()*v2.y(),
     v1.z()*v2.x() - v1.x()*v2.z(),
     v1.x()*v2.y() - v1.y()*v2.x() );
 }
开发者ID:dknutsen,项目名称:dokray,代码行数:7,代码来源:Vector.cs

示例3: rotate

 public void rotate(Vector forward, Vector side)
 {
     Matrix temp = new Matrix();
     temp.r11 = forward.x(); temp.r12 = forward.y(); temp.r13 = 0;
     temp.r21 = side.x(); temp.r22 = side.y(); temp.r23 = 0;
     temp.r31 = 0; temp.r32 = 0; temp.r33 = 1;
     this.matrixMultiply(temp);
 }
开发者ID:WildernessBob,项目名称:Game,代码行数:8,代码来源:Matrix.cs

示例4: isWalkable

 // Returns boolean for if destination Vector3 is valid
 // Vector3 created with "Vector3 destination = new Vector3(x,y,z)", with y likely to be 0
 public static bool isWalkable(Vector destination)
 {
     Vector3 temp = new Vector3((float)destination.x(),1.0f,(float)destination.y());
     Node node = AstarPath.active.GetNearest(temp).node;
     if(node.walkable){
         //Debug.Log("Valid Position");
         return true;
     }else{
         //Debug.Log("Invalid Position");
         return false;
     }
 }
开发者ID:GJL91,项目名称:Epidemic,代码行数:14,代码来源:queryPoint.cs

示例5: newPath

    public void newPath()
    {
        Vector destination = new Vector(UnityEngine.Random.Range(-200,200),UnityEngine.Random.Range(-200,200));
            while (queryPoint.isWalkable(destination) == false){
                destination = new Vector(UnityEngine.Random.Range(-200,200),UnityEngine.Random.Range(-200,200));
            }

        /*targetPosition.x = (float)aiControl.getDestinationWaypoint().x();
        targetPosition.z = (float)aiControl.getDestinationWaypoint().y();*/
        targetPosition.x = (float)destination.x();
        targetPosition.z = (float)destination.y();
        targetPosition.y = 1f;
        seeker.StartPath (transform.position,targetPosition, OnPathComplete);
    }
开发者ID:WildernessBob,项目名称:Game,代码行数:14,代码来源:AstarAI.cs

示例6: convertPointToLocalPosition

    public static Vector convertPointToLocalPosition(Vector pos, Vector entityHead,
														Vector entityHeadPerp,
														Vector entityPos)
    {
        Vector result = pos;
        Vector zero = new Vector(0,0);
        Matrix mat = new Matrix();
        double dX = zero.x() - entityPos.dotProduct(entityHead);
        double dY = zero.y() - entityPos.dotProduct(entityHeadPerp);
        mat.setR11(entityHead.x());
        mat.setR12(entityHeadPerp.x());
        mat.setR21(entityHead.y());
        mat.setR22(entityHeadPerp.y());
        mat.setR31(dX);
        mat.setR32(dY);
        mat.transformVector(result);
        return result;
    }
开发者ID:WildernessBob,项目名称:Game,代码行数:18,代码来源:MathExtension.cs

示例7: equals

 public bool equals(Vector two)
 {
     if(this.xP == two.x() && this.yP == two.y())return true;
     return false;
 }
开发者ID:GJL91,项目名称:Epidemic,代码行数:5,代码来源:Vector.cs

示例8: wallAvoidance

    Vector wallAvoidance()
    {
        //Same as above.
        this.createEntityFeelers();
        double distanceToThis = 0;
        double distanceToClosest = 9999999;
        int closestWallIndex = -1;
        Vector force = new Vector();
        Vector tempPoint = new Vector();
        Vector closestPoint = new Vector();
        ObjectBounds[] walls = WorldColliders.getObjectBoundsArray();
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < walls.length; j++){
                for(int k = 0; k < 4; k++){
                    Vector2D points = walls[j].getVertices();
                    Vector from = new Vector(points[k].x, points[k].y);
                    Vector to = new Vector(points[(k+1)&3].x, points[(k+1)&3].y);
                    Storage mathStore = MathExtension.lineIntersects2dObject(owner.getPosition(), feeler[i],
                                                            from, to,
                                                            distanceToThis, tempPoint);
                    if(mathStore.wasItTrue == true){
                        if(mathStore.dist < distanceToClosest){
                            closestWallIndex = j;
                            closestPoint.setValues(tempPoint.x(), tempPoint.y());
                        }
                    }
                    distanceToThis = mathStore.dist;
                }
                if(closestWallIndex >= 0){
                    Vector difference = feelers[i] - closestPoint;
                    Vector tempVec = to -from;
                    tempVec.normalise();
                    tempVec.setVectorToNormal();
                    force = tempVec * Math.sqrt(difference.lengthSquared());
                }

            }

        }
        return force;
    }
开发者ID:WildernessBob,项目名称:Game,代码行数:41,代码来源:SteeringBehaviour.cs

示例9: obstacleAvoidance

    Vector obstacleAvoidance()
    {
        //The obstacles for this are taken from the global object
        boxLength = SteeringBehaviour.minimumDetectionLength +
                    (Math.sqrt(owner.getCurrentSpeedSquared()/owner.getMaxSpeed())) *
                    SteeringBehaviour.minimumDetectionLength;

        ArrayList<AIEntity> list = EntityManager.globalInstance().getNeighboursInRange(owner, boxLength);
        AIEntity closestEntity = null;
        double distanceOfClosestEntity = 9999999;
        Vector positionOfClosestEntity = new Vector();
        foreach(AIEntity listIter in list){
            Vector localPosition = MathExtension.convertPointToLocalPosition(listIter.getPosition(),owner.getHeadingDirection(),owner.getPerpendicularHeading(), owner.getPosition());
            if(localPosition.x() >= 0){
                double rad = listIter.boundingRadius() + owner.boundingRadius();
                if(Math.fabs(localPosition.y()) < rad){
                    double dX = localPosition.x();
                    double dY = localPosition.y();
                    double sqrRoot = Math.sqrt(rad*rad - dY*dY);
                    double temp = dX - sqrRoot;
                    if(temp <= 0) temp = dX + sqrRoot;
                    if(temp < distanceOfClosestEntity){
                        distanceOfClosestEntity = temp;
                        closestEntity = listIter;
                        positionOfClosestEntity = localPosition;
                    }

                }
            }
        }

        Vector steeringRequiredToAvoid = new Vector(0,0);
        if(closestEntity != null){
            double mult = 1 + (SteeringBehaviour.minimumDetectionLength - positionOfClosestEntity.x()) /
                                SteeringBehaviour.minimumDetectionLength;
            steeringRequiredToAvoid.setValues(steeringRequiredToAvoid.x(),
                                                (closestEntity.boundingRadius() - positionOfClosestEntity.y()) * mult);
            double brakeVal = 0.15;
            steeringRequiredToAvoid.setValues((closestEntity.boundingRadius() - positionOfClosestEntity.x()) * brakeVal,
                                                steeringRequiredToAvoid.y());
        }
        //This may need a conversion into global space, it may not.
        return steeringRequiredToAvoid;
    }
开发者ID:WildernessBob,项目名称:Game,代码行数:44,代码来源:SteeringBehaviour.cs

示例10: accumForce

 public bool accumForce(Vector startForce, Vector forceToAdd)
 {
     double curMag = Math.sqrt(startForce.lengthSquared());
     double remaining = owner.maxForce() - curMag;
     if(remaining <= 0.0)return false;
     double magAdd = Math.sqrt(forceToAdd.lengthSquared());
     if(magAdd < remaining){
         startForce.setVectorValues(startForce.x() + forceToAdd.x(),
                             startForce.y() + forceToAdd.y());
     }else {
         Vector temp = new Vector(forceToAdd);
         temp.normalise();
         startForce.setVectorValues(temp.x()*remaining, temp.y()*remaining);
     }
     return true;
 }
开发者ID:WildernessBob,项目名称:Game,代码行数:16,代码来源:SteeringBehaviour.cs

示例11: dot

 public static float dot( Vector v1, Vector v2 )
 {
     return ( v1.x() * v2.x() ) + ( v1.y() * v2.y() ) + ( v1.z() * v2.z() );
 }
开发者ID:dknutsen,项目名称:dokray,代码行数:4,代码来源:Vector.cs

示例12: transformVector

 public void transformVector(Vector v)
 {
     double tempX = (this.r11*v.x()) + (this.r21 * v.y()) + (this.r31);
       		double tempY = (this.r12*v.x()) + (this.r22 * v.y()) + (this.r32);
       		v.setVectorValues(tempX,tempY);
 }
开发者ID:WildernessBob,项目名称:Game,代码行数:6,代码来源:Matrix.cs

示例13: setVelocity

 void setVelocity(Vector v)
 {
     velocity = new Vector(v.x(), v.y());
 }
开发者ID:WildernessBob,项目名称:Game,代码行数:4,代码来源:AIEntity.cs

示例14: setScale

 void setScale(Vector vec)
 {
     boundingRadiusOfEntity *= (((vec.x() > vec.y())?vec.x():vec.y())/
                                 ((vectorScale.x() > vectorScale.y())?
                                     vectorScale.x() : vectorScale.y()));
     vectorScale = vec;
 }
开发者ID:WildernessBob,项目名称:Game,代码行数:7,代码来源:AIEntity.cs

示例15: setPosition

 public void setPosition(Vector v)
 {
     position = new Vector(v.x(),v.y());
 }
开发者ID:WildernessBob,项目名称:Game,代码行数:4,代码来源:AIEntity.cs


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