我正在使用这个设备(http://www.sparkfun.com/products/10724),并且基于这个http://www.sparkfun.com/products/10724的磁力计、加速度计和陀螺仪数据的融合,成功地实现了相当好的工作方向估计。 x-io.co.uk/node/8#open_source_imu_and_ahrs_algorithms实现。现在我想计算动态加速度(测量没有静态重力加速度的加速度)。为此,我想到了以下想法。
计算原始加速度计数据的运行平均值。如果原始加速度稳定一段时间(运行平均值与当前测量的原始数据之间的微小差异),我们假设设备没有移动,并且我们正在测量原始重力。现在将重力矢量和当前方向保存为四元数。这种方法假设我们的设备在没有重力的情况下无法持续加速。
为了计算没有重力的加速度,我现在正在进行以下四元数计算:
RA = Quaternion with current x,y,z raw acceleration values
GA = Quaternion with x,y,z raw acceleration values of estimated gravity
CO = Quaternion of current orientation
GO = saved gravity orientation
DQ = GO^-1 * CO // difference of orientation between last gravity estimation and current orientation
DQ = DQ^-1 // get the inverse of the difference
SQ = DQ * GA * DQ^1 // rotate gravity vector
DA = RA - …Run Code Online (Sandbox Code Playgroud) 如何将自定义输入名称添加到重力表单?我需要向需要非常具体的表单名称的第三方服务提交表单。
我目前的想法是编写一些 jQuery 来在页面加载时动态重命名所有内容。显然这并不理想。
重力形式:http : //www.gravityforms.com/
我怎样才能实现重力?我做了这个: http: //jsfiddle.net/X2XvC/5/,但所有点都只是跟随你的光标(这不是重力)。我听说过欧拉方法,但我不知道如何将其实现到我的代码中。
我发现了什么:
void update(float dt)
{
position += velocity * dt + acceleration * 0.5 * dt * dt;
velocity += acceleration * dt;
}
Run Code Online (Sandbox Code Playgroud) 我是 Android 开发的新手,我正在尝试在屏幕顶部创建一个图像并使其落到底部。我一直环顾四周,无法得到正确的答案或指示。我发现的许多示例已经过时,而且许多方法不再有效。
我的 drawable 文件夹中有一个图像,我想在 10 秒后创建它,让它像有重力一样落向地面。
我已经看到很多关于 ObjectAnimator、画布、速度、动画的内容。我不知道从哪里开始。
我真的想在我的游戏中尝试引力.我知道每个人都说使用Box2D,但在我的情况下我不能.我需要使用Cocos2D来引力.
我知道Cocos2D没有内置任何重力API,因此我需要手动执行某些操作.事情就是在网络上没有任何教程或示例显示这一点.
任何人都可以告诉我他们做了什么,或者可以一步一步地解释如何应用非恒定的重力(一个在下降时稍微强一些).
我认为这将有助于许多面临同样问题的人!
谢谢!
我一直在使用C#和Winforms进行(某种)重力模拟,我得到了一些非常奇怪的行为.当你点击它时,它几乎会成为一个对象,并被其他对象吸引.问题在于,除非它们在一些奇怪的距离内,否则它们不会被吸引到正方向(向右,向下),但是它们被向上和向左吸引.
这是更新代码:
public Vector GetGravEffect(GravObject other)
{
if ((Math.Abs(X - other.X) <= Mass * Form.DrawScale + other.Mass * Form.DrawScale) &&
(Math.Abs(Y - other.Y) <= Mass * Form.DrawScale + other.Mass * Form.DrawScale))
{
return new Vector(0, 0);
}
double tAngle = Math.Atan2((other.Y - Y), (other.X - X));
double tMagnitude = (GravModifier * Mass * other.Mass / ((Math.Pow((other.X - X), 2)) + (Math.Pow((other.Y - Y), 2))) * 1000);
Complex c = Complex.FromPolarCoordinates(tMagnitude, tAngle);
Vector r = new Vector(c.Real, c.Imaginary);
return r;
} …Run Code Online (Sandbox Code Playgroud) 我的列表视图行的xml代码是
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp" />
<TextView
android:id="@+id/tv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="2"
android:gravity="center" >
<ImageView
android:id="@+id/iv_image"
android:layout_width="50dp"
android:layout_height="40dp"
android:background="@drawable/app_icon_17"
android:contentDescription="@string/empty" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="2"
android:gravity="center" >
<Button
android:id="@+id/btn_delete"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/btn_delete_new"
android:focusable="false" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我希望id为btn_delete的最后一个按钮保持右对齐.并且它在设计时以"图形布局"的形式显示.但是当我运行它时,在模拟器上它不起作用.
看输出:

那么为什么删除按钮没有正确对齐?
android gravity android-layout android-linearlayout layout-gravity
我正在使用delta时间,所以我可以使我的程序帧速率独立.但是我无法获得相同的跳跃高度,角色总是在较低的帧速率下跳得更高.
变量:
const float gravity = 0.0000000014f;
const float jumpVel = 0.00000046f;
const float terminalVel = 0.05f;
bool readyToJump = false;
float verticalVel = 0.00f;
Run Code Online (Sandbox Code Playgroud)
逻辑代码:
if(input.isKeyDown(sf::Keyboard::Space)){
if(readyToJump){
verticalVel = -jumpVel * delta;
readyToJump = false;
}
}
verticalVel += gravity * delta;
y += verticalVel * delta;
Run Code Online (Sandbox Code Playgroud)
我确定增量时间是正确的,因为角色水平移动很好.
无论帧速率如何,我如何让我的角色跳跃?
我正在使用RecyclerView Android与左/右消息框建立聊天行.我想将重力设置为RecyclerView的项目.通常情况下,我将itemView转换为LinearLayout,然后为它设置ParamLayout重力.但是如果使用RecyclerView,似乎不适合强制转换为LinearLayout.它将返回RecyclerView.LayoutParams.因为:
RecyclerView子级的LayoutParams子类.鼓励自定义布局管理器创建自己的LayoutParams类的子类,以存储有关布局的任何其他所需的每子视图元数据.
我无法找到使用RecyclerView.LayoutParams设置重力的方法:| 无论如何,任何人都可以在RecyclerView中找到重力项目的方法吗?请建议我.
----------- POST SOLUTION ------------------
// 1.RecyclerView的孩子们
<LinearLayout
android:id="@+id/id_grandparent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:divider="@android:color/transparent"
android:gravity="left"
android:orientation="vertical">
<LinearLayout
android:id="@+id/id_llparent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_customer_feedback_left"
android:gravity="left"
android:orientation="vertical">
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
// 2.OnBindView()
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params = setLayoutParamsForParent(params, item.isPosition());
holder.llParentLayout.setLayoutParams(params); //corresponding to id_llparent ID
Run Code Online (Sandbox Code Playgroud)
// 3.
private LinearLayout.LayoutParams setLayoutParamsForParent(LinearLayout.LayoutParams params, boolean position) {
params.gravity = position ? Gravity.RIGHT : Gravity.LEFT;
return params;
}
Run Code Online (Sandbox Code Playgroud) 我在我的代码中使用了G + signinbutton,它的登录工作正常.我在我的xml中使用下面的代码设置它
<com.google.android.gms.common.SignInButton
android:id="@+id/btn_sign_in"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="15dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
/>
Run Code Online (Sandbox Code Playgroud)
我现在拥有的如下

现在我想将TextView设置为按钮的中心.但是,SignInButton似乎没有android:gravity如何将我的TextView设置为居中?