我有一个Java应用程序,我写了负载了TTF字体并使用来自Graphics2D的束带方法.调用此方法与x和y位置每次使文本举动改变每隔50ms.当我在Windows上运行的程序,我得到0-1%的CPU使用率,但在Mac上,我得到约75%的使用率.这Windows机器确实有一个更好的CPU,但没有办法,应该有那么大的差别.我认为这与硬件加速有关,我想知道如何启用它.我发现了一些Mac特定的Java属性,但它们都没有降低我的CPU使用率.有关如何在OS X上提高Java 2D性能的任何想法?谢谢.
编辑1:我认为这些属性会有所帮助,但他们没有.
System.setProperty("sun.java2d.opengl", "true");
System.setProperty("apple.awt.graphics.UseQuartz","true"); System.setProperty("apple.awt.graphics.EnableQ2DX","true");
EDIT2:您可以下载该项目的源和字节代码在这里:http://drop.io/ExampleScreenSaver
编辑3:由于drop.io不再存在,我将项目上传到Google Code.现在您无需下载即可浏览代码.我仍然不知道如何处理这个问题所以任何帮助将不胜感激.
通过event.accelerationIncludingGravity在Android上使用,它返回值
x: -0.2
y: +0.1
z: +9.1
Run Code Online (Sandbox Code Playgroud)
在平坦的表面上休息时.但是,我希望在没有重力的情况下获得加速但event.acceleration不受支持.有没有办法通过数学转换它?在HTML5Rocks中有一个删除重力因子的例子,但它似乎不起作用.
// Convert the value from acceleration to degrees acceleration.x|y is the
// acceleration according to gravity, we'll assume we're on Earth and divide
// by 9.81 (earth gravity) to get a percentage value, and then multiply that
// by 90 to convert to degrees.
var tiltLR = Math.round(((acceleration.x) / 9.81) * -90);
var tiltFB = Math.round(((acceleration.y + 9.81) / 9.81) * 90 * facingUp);
Run Code Online (Sandbox Code Playgroud)
绘制加速度值的脚本示例(不是来自HTML5Rocks)
我做了一个简单的抓取演示页面.它没有任何缓和/加速.我想使用JavaScript 在kulesh.info(Flash网站)上进行相同的缓动/加速.我怎样才能做到这一点?
在JavaScript中平滑抓取(滚动,拖动)的任何示例都是有用的,也是一种语言无关的算法.
是否可以使用现有的api获取android中触摸事件的速度或速度或加速度?我已经浏览了MotionEvent类,该类中的任何字段似乎都没有检索到我需要的信息.任何帮助将不胜感激
是否有Win32 API调用来检测用户系统的当前硬件加速级别?我不需要更改设置,但是如果禁用了硬件加速,我想缩小OpenGL显示的细节级别。
我需要计算空间中的iphone速度,例如打孔速度.
我的第一个问题是:accelerometer:didAccelerate这个过滤操作的加速度值是:
gravity_x = acceleration.x * kFilteringFactor + gravity_x * (1.0 - kFilteringFactor);
gravity_y = acceleration.y * kFilteringFactor + gravity_y * (1.0 - kFilteringFactor);
gravity_z = acceleration.z * kFilteringFactor + gravity_z * (1.0 - kFilteringFactor);
float gravityNorm = sqrt(gravity_x * gravity_x + gravity_y * gravity_y + gravity_z * gravity_z);
accelX = acceleration.x - gravity_x / gravityNorm;
accelY = acceleration.y - gravity_y / gravityNorm;
accelZ = acceleration.z - gravity_z / gravityNorm;
Run Code Online (Sandbox Code Playgroud)
和使用CoreMotion一样
motionManager.deviceMotion.userAcceleration.x;
motionManager.deviceMotion.userAcceleration.y;
motionManager.deviceMotion.userAcceleration.z;?
接下来,根据相同的问题,我做以下
const float …Run Code Online (Sandbox Code Playgroud) A用Python编写的程序速度有问题.该程序是"模拟磁场中的铁磁颗粒",更具体地说是磁惰性液体.该程序可以工作,但与用C++编写的相同程序相比非常缓慢,但我用Python编写了一个项目来研究.
总的来说,程序代码基于循环,有很多浮点计算.存在随机数量的粒子(产生随机位置),其在磁场的影响下彼此相互作用.
这是最初的立场:
http://i.stack.imgur.com/T15Bb.jpg
决赛:
http://i.stack.imgur.com/0nU5D.jpg
主循环(在SymMain.py中,具有k变量)迭代是时间步长,计算当时粒子在其中的坐标和作用在其上的力(吸引力和小排斥力).为了加快速度,我想使用并行处理来同时计算迭代次数,但这是不可能的,因为一次迭代中的计算取决于前一次迭代中的计算.
我不知道Python比C++慢得多.例如,计算一次性步骤中529个粒子的模拟(在我的计算机上):
C++〜0.5s
Python~50s
那么,如何加快程序?请帮忙.
此代码仅计算,而不是像图片中那样绘制粒子.模拟partcile的数量在SymConst.py上,这是nrH*nrL.
SymMain.py
#coding:windows-1250
from os import system
from SymCalc import *
from SymParticle import *
if __name__ == '__main__':
App = SymCalc()
App.MainLoop()
Run Code Online (Sandbox Code Playgroud)
SymParticle.py
#coding:windows-1250
from random import randint
from math import *
from SymConst import *
from SymParticle import *
class SymCalc(object):
def __init__(self):
# declaration lists containing the properties of the particles
ParticleList = []
ParticleListTemp = []
t = 0.0
# the initial values ??of particle …Run Code Online (Sandbox Code Playgroud) 有没有替代RenderTargetBitmap可以生成一个与Image.Source一起使用的图像并且在.NET 3.5 sp1中是硬件加速的吗?.NET 4.0的答案很好,但我可能无法使用它们.
如果人们发现它会对我有帮助,那么他们应该为此投票.
我写过iPhone - Mac,客户端 - 服务器应用程序,允许通过触摸板使用鼠标.
现在,在每个发送的数据包上,我将光标移动到特定数量的像素(现在为10px).这不准确.当我将灵敏度改为1px时,它会变慢.
我想知道如何增强可用性和模拟鼠标加速.
有任何想法吗?
我已经找到了这个代码,它的功能是当设备动摇得足够强时做一些事情,但我还没有完全理解它.有人请帮助我
public class ShakeActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
mAccel = 0.00f;
mAccelCurrent = SensorManager.GRAVITY_EARTH;
mAccelLast = SensorManager.GRAVITY_EARTH;
}
private SensorManager mSensorManager;
private float mAccel; // acceleration apart from gravity
private float mAccelCurrent; // current acceleration including gravity
private float mAccelLast; // last acceleration including gravity
private final SensorEventListener mSensorListener = new SensorEventListener() {
public void onSensorChanged(SensorEvent se) …Run Code Online (Sandbox Code Playgroud) 我在Libgdx框架中制作平台游戏.我想实现跳到我的角色的能力.我使用简单的公式:
speed += acceleration * delta_time
r += speed * delta_time
Run Code Online (Sandbox Code Playgroud)
它运行良好,但仅适用于每秒恒定帧数.FPS越低,我的角色越低.我不知道这种行为的原因是什么,跳跃的高度应该是相同的:/我的代码片段:
delta_time=Gdx.graphics.getDeltaTime();
if(input.getUpArrow()){
if(is_in_air==false){
is_in_air=true;
speed_y=speed_y_0;
}
}
if(is_in_air==true){
speed_y-=acceleration*delta_time;
}
else{
speed_y=0;
}
x+=speed_x*delta_time;
y+=speed_y*delta_time;
Run Code Online (Sandbox Code Playgroud)
这里有一个插图(黑点是字符位置):http: //i.imgur.com/tfSTM.jpg
我正在使用来自设备的加速度值(x,y,z)进行手势操作.
如果我把手中的设备放在静止位置(x,y,z)=((0,0,0)).但是,如果我改变设备的方向(仍处于静止位置),则值将更改为((766,766,821)).由于所有x,y,z轴与其原始方向相比都发生了变化.
有没有办法(三角函数或其他)来解决这个问题?
情况就是这样.我在服务器A上有一个远程git存储库.另外,我必须在这个存储库中使用相同的源代码处理桌面B. 由于访问服务器A的带宽有限,我想在桌面B上为存储库设置本地镜像.
现在,我已经设置了镜像存储库
git clone --mirror https://repository-on-server-a /local/repo/path.git
Run Code Online (Sandbox Code Playgroud)
我已经测试了本地存储库
git clone file://localhost/local/repo/path.git
Run Code Online (Sandbox Code Playgroud)
然后我修改了crontab来做
cd /local/repo/path git fetch -q
Run Code Online (Sandbox Code Playgroud)
每5分钟同步一次.它运作良好.
一开始,我正在考虑使用
git config --global url.file://localhost/local/repo/path.git.insteadOf https://repository-on-server-a
Run Code Online (Sandbox Code Playgroud)
让git从本地目录而不是远程仓库获取所有对象.但是,它不起作用.
我的问题是
本地目录用于测试,但不是最终解决方案.我将有另一个桌面C以便稍后从桌面B获取源代码.另一位同事也会加入我的行列.这意味着我们希望将桌面B中的所有更改都为我们提供一些"中心"解决方案.
acceleration ×13
android ×2
hardware ×2
java ×2
javascript ×2
physics ×2
core-motion ×1
frame-rate ×1
git ×1
html5 ×1
ios ×1
iphone ×1
libgdx ×1
macos ×1
mirror ×1
mouse ×1
objective-c ×1
opengl ×1
particles ×1
performance ×1
python ×1
silverlight ×1
simulation ×1
touch ×1
velocity ×1
wpf ×1