• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FastMath类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.oscim.utils.FastMath的典型用法代码示例。如果您正苦于以下问题:Java FastMath类的具体用法?Java FastMath怎么用?Java FastMath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FastMath类属于org.oscim.utils包,在下文中一共展示了FastMath类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: update

import org.oscim.utils.FastMath; //导入依赖的package包/类
@Override
public void update(GLViewport v) {
    if (!mInitialized) {
        init();
        mInitialized = true;
    }

    if (!isEnabled()) {
        setReady(false);
        return;
    }

    if (!v.changed() && !mReanimated && !isReady())
        return;

    setReady(true);

    // clamp location to a position that can be
    // safely translated to screen coordinates
    v.getBBox(mBBox, 0);

    mLocationIsVisible = mBBox.contains(mLocation);
    mIndicatorPosition.x = FastMath.clamp(mLocation.x, mBBox.xmin, mBBox.xmax);
    mIndicatorPosition.y = FastMath.clamp(mLocation.y, mBBox.ymin, mBBox.ymax);
}
 
开发者ID:andreynovikov,项目名称:trekarta,代码行数:26,代码来源:LocationOverlay.java


示例2: scaleMap

import org.oscim.utils.FastMath; //导入依赖的package包/类
/**
 * Scale map by scale width center at pivot in pixel relative to
 * screen center. Map scale is clamp to MIN_SCALE and MAX_SCALE.
 * 
 * @param scale
 * @param pivotX
 * @param pivotY
 * @return true if scale was changed
 */
public synchronized boolean scaleMap(float scale, float pivotX, float pivotY) {
	// just sanitize input
	//scale = FastMath.clamp(scale, 0.5f, 2);
	if (scale < 0.000001)
		return false;

	double newScale = mPos.scale * scale;

	newScale = FastMath.clamp(newScale, MIN_SCALE, MAX_SCALE);

	if (newScale == mPos.scale)
		return false;

	scale = (float) (newScale / mPos.scale);

	mPos.scale = newScale;

	if (pivotX != 0 || pivotY != 0)
		moveMap(pivotX * (1.0f - scale),
		        pivotY * (1.0f - scale));

	return true;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:33,代码来源:ViewController.java


示例3: getMapPosition

import org.oscim.utils.FastMath; //导入依赖的package包/类
/**
 * Get the current MapPosition.
 * 
 * @param pos MapPosition to be updated.
 * 
 * @return true iff current position is different from
 *         passed position.
 */
public synchronized boolean getMapPosition(MapPosition pos) {

	boolean changed = (pos.scale != mPos.scale
	        || pos.x != mPos.x
	        || pos.y != mPos.y
	        || pos.bearing != mPos.bearing
	        || pos.tilt != mPos.tilt);

	pos.bearing = mPos.bearing;
	pos.tilt = mPos.tilt;

	pos.x = mPos.x;
	pos.y = mPos.y;
	pos.scale = mPos.scale;
	pos.zoomLevel = FastMath.log2((int) mPos.scale);

	return changed;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:27,代码来源:Viewport.java


示例4: getMapPosition

import org.oscim.utils.FastMath; //导入依赖的package包/类
/**
 * Get the current MapPosition
 *
 * @param pos MapPosition object to be updated
 * @return true if current position is different from 'pos'.
 */
public synchronized boolean getMapPosition(MapPosition pos) {

	boolean changed = (pos.x != mAbsX || pos.y != mAbsY
			|| pos.scale != mAbsScale
			|| pos.angle != mRotation
			|| pos.tilt != mTilt);

	if (!changed)
		return false;

	int z = FastMath.log2((int) mAbsScale);

	pos.angle = mRotation;
	pos.tilt = mTilt;

	pos.x = mAbsX;
	pos.y = mAbsY;
	pos.scale = mAbsScale;

	pos.zoomLevel = z;

	return true;
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:30,代码来源:MapViewPosition.java


示例5: moveAbs

import org.oscim.utils.FastMath; //导入依赖的package包/类
private synchronized void moveAbs(double x, double y) {
	double f = Tile.SIZE << ABS_ZOOMLEVEL;

	mAbsX = x / f;
	mAbsY = y / f;

	// clamp latitude
	mAbsY = FastMath.clamp(mAbsY, 0, 1);

	// wrap longitude
	while (mAbsX > 1)
		mAbsX -= 1;
	while (mAbsX < 0)
		mAbsX += 1;

	updatePosition();
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:18,代码来源:MapViewPosition.java


示例6: animateFling

import org.oscim.utils.FastMath; //导入依赖的package包/类
public synchronized void animateFling(int velocityX, int velocityY,
		int minX, int maxX, int minY, int maxY) {

	if (velocityX * velocityX + velocityY * velocityY < 4096)
		return;

	mScrollX = 0;
	mScrollY = 0;

	float duration = 500;

	// pi times thumb..
	float flingFactor = (duration / 2500);
	mVelocityX = velocityX * flingFactor;
	mVelocityY = velocityY * flingFactor;
	FastMath.clamp(mVelocityX, minX, maxX);
	FastMath.clamp(mVelocityY, minY, maxY);

	mAnimFling = true;
	mAnimMove = false;
	mAnimScale = false;
	animStart(duration);
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:24,代码来源:MapViewPosition.java


示例7: moveTo

import org.oscim.utils.FastMath; //导入依赖的package包/类
void moveTo(double x, double y) {
	mPos.x = x;
	mPos.y = y;

	/* clamp latitude */
	mPos.y = FastMath.clamp(mPos.y, 0, 1);

	/* wrap longitude */
	while (mPos.x > 1)
		mPos.x -= 1;
	while (mPos.x < 0)
		mPos.x += 1;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:14,代码来源:ViewController.java


示例8: setTilt

import org.oscim.utils.FastMath; //导入依赖的package包/类
public synchronized boolean setTilt(float tilt) {
	tilt = FastMath.clamp(tilt, 0, MAX_TILT);
	if (tilt == mPos.tilt)
		return false;
	mPos.tilt = tilt;
	updateMatrices();
	return true;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:9,代码来源:ViewController.java


示例9: setMapPosition

import org.oscim.utils.FastMath; //导入依赖的package包/类
public synchronized void setMapPosition(MapPosition mapPosition) {
	mPos.scale = FastMath.clamp(mapPosition.scale, MIN_SCALE, MAX_SCALE);
	mPos.x = mapPosition.x;
	mPos.y = mapPosition.y;
	mPos.tilt = mapPosition.tilt;
	mPos.bearing = mapPosition.bearing;
	updateMatrices();
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:9,代码来源:ViewController.java


示例10: onMapEvent

import org.oscim.utils.FastMath; //导入依赖的package包/类
@Override
public void onMapEvent(Event event, MapPosition pos) {
	super.onMapEvent(event, pos);

	if (event != Map.POSITION_EVENT)
		return;

	FadeStep[] fade = mTileSource.getFadeSteps();

	if (fade == null) {
		//mRenderLayer.setBitmapAlpha(1);
		return;
	}

	float alpha = 0;
	for (FadeStep f : fade) {
		if (pos.scale < f.scaleStart || pos.scale > f.scaleEnd)
			continue;

		if (f.alphaStart == f.alphaEnd) {
			alpha = f.alphaStart;
			break;
		}
		double range = f.scaleEnd / f.scaleStart;
		float a = (float) ((range - (pos.scale / f.scaleStart)) / range);
		a = FastMath.clamp(a, 0, 1);
		// interpolate alpha between start and end
		alpha = a * f.alphaStart + (1 - a) * f.alphaEnd;
		break;
	}

	tileRenderer().setBitmapAlpha(alpha);
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:34,代码来源:BitmapTileLayer.java


示例11: getFade

import org.oscim.utils.FastMath; //导入依赖的package包/类
public float getFade(double scale) {
	if (fadeScale < 0)
		return 1;

	float f = (float) (scale / (1 << fadeScale)) - 1;
	return FastMath.clamp(f, FADE_START, 1);
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:8,代码来源:AreaStyle.java


示例12: getBlend

import org.oscim.utils.FastMath; //导入依赖的package包/类
public float getBlend(double scale) {
	if (blendScale < 0)
		return 0;

	float f = (float) (scale / (1 << blendScale)) - 1;
	return FastMath.clamp(f, 0, 1);
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:8,代码来源:AreaStyle.java


示例13: fadePremul

import org.oscim.utils.FastMath; //导入依赖的package包/类
public static int fadePremul(int color, double alpha) {
	alpha = FastMath.clamp(alpha, 0, 1);

	alpha *= (color >>> 24) & 0xff;
	int c = (((int) alpha) & 0xff) << 24;

	alpha /= 255;

	c |= ((int) (alpha * ((color >>> 16) & 0xff))) << 16;
	c |= ((int) (alpha * ((color >>> 8) & 0xff))) << 8;
	c |= ((int) (alpha * (color & 0xff)));

	return c;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:15,代码来源:Color.java


示例14: fade

import org.oscim.utils.FastMath; //导入依赖的package包/类
public static int fade(int color, double alpha) {
	alpha = FastMath.clamp(alpha, 0, 1);

	alpha *= (color >>> 24) & 0xff;
	int c = (((int) alpha) & 0xff) << 24;

	return c | (color & 0x00ffffff);
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:9,代码来源:Color.java


示例15: GeoPoint

import org.oscim.utils.FastMath; //导入依赖的package包/类
/**
 * @param lat
 *            the latitude in degrees, will be limited to the possible
 *            latitude range.
 * @param lon
 *            the longitude in degrees, will be limited to the possible
 *            longitude range.
 */
public GeoPoint(double lat, double lon) {
	lat = FastMath.clamp(lat,
	                     MercatorProjection.LATITUDE_MIN,
	                     MercatorProjection.LATITUDE_MAX);
	this.latitudeE6 = (int) (lat * CONVERSION_FACTOR);
	lon = FastMath.clamp(lon,
	                     MercatorProjection.LONGITUDE_MIN,
	                     MercatorProjection.LONGITUDE_MAX);
	this.longitudeE6 = (int) (lon * CONVERSION_FACTOR);
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:19,代码来源:GeoPoint.java


示例16: set

import org.oscim.utils.FastMath; //导入依赖的package包/类
public void set(double x, double y, double scale, float bearing, float tilt) {
	this.x = x;
	this.y = y;
	this.scale = scale;

	while (bearing > 180)
		bearing -= 360;
	while (bearing < -180)
		bearing += 360;
	this.bearing = bearing;

	this.tilt = tilt;
	this.zoomLevel = FastMath.log2((int) scale);
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:15,代码来源:MapPosition.java


示例17: move

import org.oscim.utils.FastMath; //导入依赖的package包/类
private synchronized void move(double mx, double my) {
	mAbsX = (mCurX - mx) / mCurScale;
	mAbsY = (mCurY - my) / mCurScale;

	// clamp latitude
	mAbsY = FastMath.clamp(mAbsY, 0, 1);

	// wrap longitude
	while (mAbsX > 1)
		mAbsX -= 1;
	while (mAbsX < 0)
		mAbsX += 1;

	updatePosition();
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:16,代码来源:MapViewPosition.java


示例18: scaleMap

import org.oscim.utils.FastMath; //导入依赖的package包/类
/**
 * @param scale map by this factor
 * @param pivotX ...
 * @param pivotY ...
 * @return true if scale was changed
 */
public synchronized boolean scaleMap(float scale, float pivotX, float pivotY) {
	// stop animation
	animCancel();

	// just sanitize input
	scale = FastMath.clamp(scale, 0.5f, 2);

	double newScale = mAbsScale * scale;

	newScale = FastMath.clamp(newScale, MIN_SCALE, MAX_SCALE);

	if (newScale == mAbsScale)
		return false;

	scale = (float) (newScale / mAbsScale);

	mAbsScale = newScale;

	if (pivotX != 0 || pivotY != 0)
		moveMap(pivotX * (1.0f - scale),
				pivotY * (1.0f - scale));
	else
		updatePosition();

	return true;
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:33,代码来源:MapViewPosition.java


示例19: setTilt

import org.oscim.utils.FastMath; //导入依赖的package包/类
public synchronized boolean setTilt(float tilt) {
	tilt = FastMath.clamp(tilt, 0, MAX_TILT);
	if (tilt == mTilt)
		return false;
	mTilt = tilt;
	updateMatrix();
	return true;
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:9,代码来源:MapViewPosition.java


示例20: setMapPosition

import org.oscim.utils.FastMath; //导入依赖的package包/类
public synchronized void setMapPosition(MapPosition mapPosition) {
	mAbsScale = FastMath.clamp(mapPosition.scale, MIN_SCALE, MAX_SCALE);
	mAbsX = mapPosition.x;
	mAbsY = mapPosition.y;
	mTilt = mapPosition.tilt;
	mRotation = mapPosition.angle;
	updatePosition();
	updateMatrix();
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:10,代码来源:MapViewPosition.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContentType类代码示例发布时间:2022-05-23
下一篇:
Java SerializerException类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap