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


Java Vector2d.scale方法代码示例

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


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

示例1: adjacentDist

import javax.vecmath.Vector2d; //导入方法依赖的package包/类
public double adjacentDist(Line l, Point2d pt) {

		Vector2d v1 = new Vector2d(l.end);
		v1.sub(l.start);
		Vector2d v2 = new Vector2d(pt);
		v2.sub(l.start);
		double param = v2.dot(v1) / v1.length();

		if ( param < 0 || param > v1.length() )
			return Double.MAX_VALUE;
		
		v1.normalize();
		v1.scale( param );
		v1.add( l.start );
		
		return new Point2d (v1).distance(pt);
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:18,代码来源:FacadeFinder.java

示例2: project

import javax.vecmath.Vector2d; //导入方法依赖的package包/类
public static Point2d project(Line l, Point2d pt) {
	
	Vector2d v1 = new Vector2d(l.end);
	v1.sub(l.start);
	Vector2d v2 = new Vector2d(pt);
	v2.sub(l.start);
	double param = v2.dot(v1) / v1.length();

	if (param < 0 || param > v1.length())
		return null;

	v1.normalize();
	v1.scale(param);
	v1.add(l.start);

	return new Point2d(v1);
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:18,代码来源:Concarnie.java

示例3: computeTreeCollisionVector

import javax.vecmath.Vector2d; //导入方法依赖的package包/类
/**If it's really the front collision, the "mirror vector" is returned. Otherwise the unchanged parameter normal is returned.*/
private Vector3d computeTreeCollisionVector(Vector3d normal) {        
    Vector3d av = botself.getVelocity().getVector3d();
    /* Jestliže signalizuje pravý přední paprsek a ne levý přední -
     * a navíc jde normálová síla v místě kolize stejným směrem jako jde paprsek, tedy doleva ==> pak by se neměla přičítat tato normála, ale spíše síla na durhou stranu.
     * Značí to situaci, kdy jsme narazili na úzkou překážku (strom) a levý přední paprsek prošel levým krajem překážky.
     * Bez tohoto ošetření by nás to stočilo doleva, což nechceme.*/
    /* Pro pravou stranu je to naopak. *//* Jestliže signalizuje levý přední paprsek a ne pravý přední -
     * a navíc jde normálová síla v místě kolize stejným směrem jako jde paprsek, tedy doleva ==> pak by se neměla přičítat tato normála, ale spíše síla na durhou stranu.
     * Značí to situaci, kdy jsme narazili na úzkou překážku (strom) a levý přední paprsek prošel levým krajem překážky.
     * Bez tohoto ošetření by nás to stočilo doleva, což nechceme.*/

    Vector2d start = new Vector2d(botself.getLocation().x, botself.getLocation().y);
    Vector2d end = new Vector2d(start.x-av.x, start.y-av.y);
    Vector2d point = new Vector2d(start.x + normal.x, start.y + normal.y);
    Vector2d pata = SteeringTools.getNearestPoint(start, end, point, false);
    Vector2d pointToPata = new Vector2d(pata.x - point.x, pata.y - point.y);
    pointToPata.scale(2);
    Vector2d mirrorPoint = new Vector2d(point.x + pointToPata.x, point.y + pointToPata.y);
    
    Vector3d result = new Vector3d(mirrorPoint.x - start.x, mirrorPoint.y - start.y, 0);
    
    if (SteeringManager.DEBUG) {
        System.out.println("Obstacle avoidance tree collision. " + result.length());
    }
    return result;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:28,代码来源:ObstacleAvoidanceSteer.java

示例4: getShortestPath

import javax.vecmath.Vector2d; //导入方法依赖的package包/类
/**
 * Liefert den kuerzesten Pfad von einem bestimmten Punkt aus zum Ziel
 * 
 * @param from
 *            Startpunkt in weltkoordinaten
 * @return Liste der Turningpoints (Gitterkoordinaten!!!)
 */
public Vector<TurningPoint> getShortestPath(Vector2d from) {
	Vector2d f = new Vector2d(from);
	f.scale(1 / blockSizeInM);

	TurningPoint start = new TurningPoint(f);

	if (finishPositions.size() == 0) {
		return null;
	}

	Iterator<Vector2d> it = finishPositions.iterator();

	double dist = java.lang.Double.MAX_VALUE;
	Vector<TurningPoint> shortestPath = null;

	while (it.hasNext()) {
		Vector2d fin = new Vector2d(it.next());
		fin.add(new Vector2d(0.5, 0.5));
		TurningPoint finish = new TurningPoint(fin);

		Vector<TurningPoint> tmpShortestPath = start.getShortestPathTo(finish, getFlatParcours());

		double tmpDist = TurningPoint.getLengthOfPath(tmpShortestPath);
		if (tmpDist < dist) {
			shortestPath = tmpShortestPath;
			dist = tmpDist;
		}
	}

	// finde die kuerzeste Verbindung
	return shortestPath;
}
 
开发者ID:tsandmann,项目名称:ct-sim,代码行数:40,代码来源:Parcours.java

示例5: updateMarkers

import javax.vecmath.Vector2d; //导入方法依赖的package包/类
public void updateMarkers( Bar b )
{
    for (Marker m : b.mould.getAnchorsReadOnly( b.start, b.end ) )
    {
        Vector2d dir = new Vector2d (b.end);
        dir.sub(b.start);
        
        dir.scale( Mathz.clamp( weights.get (b), 0.1, 0.9 ) );
        dir.add(b.start);
        m.set( dir );

        m.bar = b;
    }
}
 
开发者ID:twak,项目名称:campskeleton,代码行数:15,代码来源:WeightedPointEditor.java

示例6: add

import javax.vecmath.Vector2d; //导入方法依赖的package包/类
private void add(List<Marker> out, Point2d relStart, Point2d relEnd, Bar b, boolean rel)
{
    Vector2d delta = new Vector2d(relEnd);
    delta.sub(relStart);


    for (PMarker pm : generators)
    {
        if (pm.rel == rel)
        {
            Vector2d d2 = new Vector2d(delta);
            d2.scale(pm.param);
            d2.add(relStart);
            Marker o = new Marker();
            o.bar = b;
            o.set(d2);


            if (b != null)
            {
                o.bar = b;
            }

            out.add(o);
            o.generator = pm;
        }
    }
}
 
开发者ID:twak,项目名称:campskeleton,代码行数:29,代码来源:NaiveMould.java

示例7: createDormerWindowsFor

import javax.vecmath.Vector2d; //导入方法依赖的package包/类
public void createDormerWindowsFor(Bar b, double desiredSpacing )
{
    b.mould.clear();
    
    double length = b.length();
    int count = (int)(length /desiredSpacing);
    double delta = length / (count+1.);
    Vector2d v = new Vector2d (b.end);
    v.sub(b.start);
    v.normalize();
    v.scale(delta);
    
    for (int i = 1; i <= count; i++)
    {
        Vector2d loc = new Vector2d (v);
        loc.scale(i);
        loc.add(b.start);
        Marker m = new Marker();
        m.set(loc);
        m.bar = b;
        
        b.mould.create(m, null);

        Marker profM =  profileMarkers.get( profiles.get(b));


        if (profM != null) {
            Ship.Instance instance = ns.newInstance();
            instance.anchors = new Anchor[]{new Anchor(m.generator, profM.generator)};
        }
    }
}
 
开发者ID:twak,项目名称:siteplan,代码行数:33,代码来源:OverhangPlan.java

示例8: returnLineTo

import javax.vecmath.Vector2d; //导入方法依赖的package包/类
/**
 * gibt einen Polygonzug der mit Breite und einer Spitze versehen Linie von
 * this zu p2 zurueck, zur Weiterverwendung in createLine()
 *
 * @param p2
 * @return {x1,y1,z1,x2,y2,z2,...,x6,y6,z6}
 */
float[] returnLineTo(TurningPoint p2) {
	Vector2d offset = new Vector2d(0.5, 0.5);
	Vector2d length = new Vector2d(p2.pos);
	length.sub(this.pos);
	Vector2d halfWidth = new Vector2d(-length.y, length.x);
	halfWidth.normalize();
	halfWidth.scale(lineWidth / 2);
	Vector2d corner = new Vector2d(this.pos);
	// corner.add(new Vector2d(0.5,0.5));
	corner.sub(halfWidth);
	corner.sub(offset);
	float[] polygon = new float[18];
	polygon[0] = (float) corner.x;
	polygon[1] = (float) corner.y;
	polygon[2] = height;
	corner.add(length);
	polygon[3] = (float) corner.x;
	polygon[4] = (float) corner.y;
	polygon[5] = height;
	corner.add(halfWidth);
	corner.add(halfWidth);
	polygon[6] = (float) corner.x;
	polygon[7] = (float) corner.y;
	polygon[8] = height;
	corner.sub(length);
	polygon[9] = (float) corner.x;
	polygon[10] = (float) corner.y;
	polygon[11] = height;
	corner.sub(halfWidth);
	Vector2d head = new Vector2d(length);
	head.normalize();
	head.scale(-lineWidth / 2);
	corner.add(head);
	polygon[12] = (float) corner.x;
	polygon[13] = (float) corner.y;
	polygon[14] = height;
	corner.sub(halfWidth);
	corner.sub(head);
	polygon[15] = (float) corner.x;
	polygon[16] = (float) corner.y;
	polygon[17] = height;
	return polygon;
}
 
开发者ID:tsandmann,项目名称:ct-sim,代码行数:51,代码来源:TurningPoint.java

示例9: setPlan

import javax.vecmath.Vector2d; //导入方法依赖的package包/类
private void setPlan(Marker planC, double distance, Marker planM) {
            
            // we always trail by 1 frame, but this can't really be helped.
            Bar bar = planC.bar;
//            Loop<Bar> loop = null;
//            Loopable<Bar> able = null;

            LoopLoopable<Bar>
                cAble = Siteplan.instance.plan.points.find( bar ),
                mAble = Siteplan.instance.plan.points.find( planM.bar );

            if ( cAble == null || mAble == null )
                return; // didn't find marker on main plan. give up.

            // remove plan marker from old location
            Object generator = planM.bar.mould.remove( planM );
            
            // anchors may have re-genereated. grab the most recent location
            planC = refresh (planC, cAble );
//            planM = refresh (planM, mAble);

//            Object generator = mAble.loopable.get().mould.remove( planM );

            // move plan marker - find correct bar by subtracting from desired distance

            double leftInBar;

            Loopable<Bar> able = cAble.loopable;

            if ( distance > 0 )
            {
                leftInBar = planC.distance( able.get().end );

                do
                    if ( leftInBar > distance )
                    {
                        leftInBar -= distance;
                        break;
                    }
                    else
                    {
                        distance -= leftInBar;
                        able = able.getNext();
                        leftInBar = able.get().length();
                    }
                while ( true );
            }
            else
            {
                distance = -distance;
                leftInBar = planC.distance( able.get().start );

                do
                    if ( leftInBar > distance )
                    {
                        leftInBar -= distance;
                        leftInBar = able.get().length() - leftInBar;
                        break;
                    }
                    else
                    {
                        distance -= leftInBar;
                        able = able.getPrev();
                        leftInBar = able.get().length();
                    }
                while ( true );
            }

            planM.bar = able.get();

            // calculate position as distance from end
            Vector2d dir = new Vector2d (planM.bar.end );
            dir.sub( planM.bar.start );
            dir.normalize();
            dir.scale( -leftInBar );
            dir.add( planM.bar.end );

            planM.set( dir );

            planM.bar.mould.create( planM, generator );
        }
 
开发者ID:twak,项目名称:siteplan,代码行数:82,代码来源:AnimateAnchorCircularShip.java


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