You confuse me:
I thought a and b are float vectors - that is, vectors containing
actual numbers, not pointers (for example to a Float class). As such,
you can not .clone() them.
Did you use Float (with capital F) instead of float (with lower case
f)?
Floats are classes surrounding float.
If
Sorry for the confusion. I have another place in the application where
I am copying an array of objects. That is what I used for testing.
Rud
On Aug 26, 6:05 am, Peli peli0...@googlemail.com wrote:
You confuse me:
I thought a and b are float vectors - that is, vectors containing
actual
Hi,
The code is originally from my Blog. The reason for the clone is
explained there.
I admit to not having worked with Java enough to have the deep
understanding of how containers deal with objects. In my application I
ran into a problem trying to make a copy of an array and had to write
my
To deep copy an array, you can use System.arraycopy(..)
http://developer.android.com/reference/java/lang/System.html#arraycopy%28java.lang.Object,%20int,%20java.lang.Object,%20int,%20int%29
System.arraycopy(b, 0, a, 0, 3);
but for a float array of length 3, you can simply write
a[0]=b[0];
I'm trying to get the acceleration values in the earth coordinate
system. E.g. instead of knowing the phone is accelerating
+Z in the phone's coordinate system I'd like to know if
the phone is accelerating upwards relative to the earth.
Seems like it's almost there since I can get the phone's
System.arraycopy does not do a deep copy. I just tried it. But it is
very fast. grin
I setup the timing test. I did 5000 passes over the copy loops;
522 msfor (i=0; i3; i++) a[i] = b[i].clone();
453 msfor(i=3; i--0;) a[i] = b[i].clone();
447 msint pos = 0; for(type x; b)
I must be dense but can't seem to make the documentation around this
make
sense. I can compute the phone orientation in earth-relative
coordinates but
can't figure out how to get the phone-relative acceleration values
expressed
in the earth coordinate system.
I tried multiplying the rotation
= event.values.clone();
Note that this creates new objects constantly that have to be garbage
collected later. Depending on the kind of application, it may be
better to just copy the values into a persisting array.
Peli
www.openintents.org
On Aug 21, 4:06 am, mscwd01 mscw...@gmail.com
Thanks, that seems to work, the orientation is now relative to the
earth. The documentation could use a little work...
mike
On Aug 20, 7:08 pm, mscwd01 mscw...@gmail.com wrote:
Oh and you'll need these:
final int matrix_size = 16;
float[] R = new float[matrix_size];
float[] outR = new
Heres my code, which works:
public void onSensorChanged(SensorEvent event) {
Sensor sensor = event.sensor;
int type = sensor.getType();
switch (type) {
case Sensor.TYPE_MAGNETIC_FIELD:
mags = event.values.clone();
Oh and you'll need these:
final int matrix_size = 16;
float[] R = new float[matrix_size];
float[] outR = new float[matrix_size];
float[] I = new float[matrix_size];
float[] values = new float[3];
On Aug 21, 3:06 am, mscwd01 mscw...@gmail.com wrote:
Heres my code, which works:
public void
11 matches
Mail list logo