Button checkboxMagnetic;
Button checkboxTilt;
Button button01, button02, button03;
+ Button withAxisCheck;
private Text dataText;
Timer dataOutputTimer;
panelComposite.setLayoutData(gd);
// Create composite containing moving type selection radio buttons
- Composite radioComposite = formUtil.createComposite(mobileComposite, 3);
+ Composite radioComposite = formUtil.createComposite(mobileComposite, 4);
gd = new GridData(SWT.CENTER, SWT.FILL, false, true);
radioComposite.setLayoutData(gd);
- button01 = formUtil.createButton(radioComposite, "X/Z ", SWT.RADIO);
+ button01 = formUtil.createButton(radioComposite, "X/Z", SWT.RADIO);
button01.setSelection(true);
mode = Mode.YAW_PITCH;
button01.addSelectionListener(new SelectionAdapter() {
super.widgetSelected(e);
}
});
- button02 = formUtil.createButton(radioComposite, "X/Y ", SWT.RADIO);
+ button02 = formUtil.createButton(radioComposite, "X/Y", SWT.RADIO);
button02.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
}
});
+ withAxisCheck = formUtil.createButton(radioComposite, "With axis", SWT.CHECK);
+ withAxisCheck.setSelection(false);
+ withAxisCheck.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if(withAxisCheck.getSelection())
+ panel.isWithAxis = true;
+ else
+ panel.isWithAxis = false;
+ super.widgetSelected(e);
+ }
+ });
// Create text (data output)
public boolean phone_pos_conv = false;
public IDevice currentDevice;
+ public boolean isWithAxis = false;
/*
* http://code.google.com/android/reference/android/hardware/Sensors.html
* surface.
*/
// Mobile size
- final double sx = 15; // size x
- final double sy = 40; // size y
- final double sz = 5; // size z
+ final double sx = 15 * 1.4; // size x
+ final double sy = 40 * 1.4; // size y
+ final double sz = 5 * 1.4; // size z
// Display size
- final double dx = 12; // size x
- final double dy1 = 33; // size y
- final double dy2 = -15;
+ final double dx = 12 * 1.4; // size x
+ final double dy1 = 33 * 1.4; // size y
+ final double dy2 = -15 * 1.4;
+
+ // for axis display
+ final double xAxisLen = 35;
+ final double yAxisLen = 75;
+ final double zAxisLen = 25;
/** Contains the grid model of the phone. */
double[][] phone = {
{-dx, dy1, sz}, {-dx, dy2, sz},
{-dx, dy2, sz}, { dx, dy2, sz},
{ dx, dy2, sz}, { dx, dy1, sz},
+ // x axis
+ { xAxisLen, 0, 0 }, { 0, 0, 0 },
+ // y axis
+ { 0, yAxisLen, 0 }, { 0, 0, 0 },
+ // z axis
+ { 0, 0, zAxisLen }, { 0, 0, 0 },
};
private Timer timer;
private Timer geomagneticTimer;
mPage.button02.setSelection(false);
mPage.button03.setSelection(false);
mPage.mode = Mode.YAW_PITCH;
+ mPage.withAxisCheck.setSelection(false);
mPage.checkboxAcceleration.setSelection(true);
mPage.panel.accelerometerTimer(mPage.checkboxAcceleration.getSelection());
double draw_roll = old_gyro_rollDegree - rollDegree;
double draw_pitch = old_gyro_pitchDegree-pitchDegree;
double draw_yaw = old_gyro_yawDegree-yawDegree;
+ int vector_len = phone.length;
+ if(!isWithAxis)
+ vector_len = 32;
- for (int i=0; i<phone.length; i+=2) {
- if (i==0) g2.setColor(Color.RED);
- if (i==24) g2.setColor(Color.BLUE);
-
- Vector v1 = new Vector(phone[i]);
- Vector v2 = new Vector(phone[i+1]);
- if( i == 0 ) {
- v1.setAxisX(gyro_axisX);
- v1.setAxisY(gyro_axisY);
- v1.setAxisZ(gyro_axisZ);
- v1.rollpitchyaw(draw_roll, draw_pitch, draw_yaw);
- }
-
- v1.setPosition();
- v2.setPosition();
-
- if (phone_pos_conv == true) {
- if( i == 30){
- phone_pos_conv = false;
-
- gyro_axisX = Vector.getAxisX().clone();
- gyro_axisY = Vector.getAxisY().clone();
- gyro_axisZ = Vector.getAxisZ().clone();
-
- old_gyro_rollDegree = rollDegree;
- old_gyro_pitchDegree = pitchDegree;
- old_gyro_yawDegree = yawDegree;
- }
- }
-
- g2.draw(new Line2D.Double(
- centerx + (v1.x + movex) * centerz / (centerz - v1.y),
- centery - (v1.z + movez) * centerz / (centerz - v1.y),
- centerx + (v2.x + movex) * centerz / (centerz - v2.y),
- centery - (v2.z + movez) * centerz / (centerz - v2.y)));
- }
-
-
- // Now we also draw the acceleration:
- g2.setColor(Color.GREEN);
- Vector v1 = new Vector(0,0,0);
- Vector v2 = new Vector(accelx, accely, accelz);
- v2.scale(20 * ginverse);
+ for (int i=0; i<vector_len; i+=2) {
+ if (i==0) g2.setColor(Color.RED);
+ if (i==24) g2.setColor(Color.BLUE);
+ if (i==32) g2.setColor(Color.BLACK);
+
+ Vector v1 = new Vector(phone[i]);
+ Vector v2 = new Vector(phone[i+1]);
+ if( i == 0 ) {
+ v1.setAxisX(gyro_axisX);
+ v1.setAxisY(gyro_axisY);
+ v1.setAxisZ(gyro_axisZ);
+ v1.rollpitchyaw(draw_roll, draw_pitch, draw_yaw);
+ }
+
v1.setPosition();
v2.setPosition();
- g2.draw(new Line2D.Double(
+
+ if (phone_pos_conv == true) {
+ if( i == vector_len - 2){
+ phone_pos_conv = false;
+
+ gyro_axisX = Vector.getAxisX().clone();
+ gyro_axisY = Vector.getAxisY().clone();
+ gyro_axisZ = Vector.getAxisZ().clone();
+
+ old_gyro_rollDegree = rollDegree;
+ old_gyro_pitchDegree = pitchDegree;
+ old_gyro_yawDegree = yawDegree;
+ }
+ }
+
+ g2.draw(new Line2D.Double(
centerx + (v1.x + movex) * centerz / (centerz - v1.y),
centery - (v1.z + movez) * centerz / (centerz - v1.y),
centerx + (v2.x + movex) * centerz / (centerz - v2.y),
centery - (v2.z + movez) * centerz / (centerz - v2.y)));
-
+
+ if (i==32)
+ g2.drawString(" x+", (float)(centerx + (v1.x + movex) * centerz / (centerz - v1.y)), (float)(centery - (v1.z + movez) * centerz / (centerz - v1.y)));
+
+ if (i==34)
+ g2.drawString(" y+", (float)(centerx + (v1.x + movex) * centerz / (centerz - v1.y)), (float)(centery - (v1.z + movez) * centerz / (centerz - v1.y)));
+
+ if (i==36)
+ g2.drawString(" z+", (float)(centerx + (v1.x + movex) * centerz / (centerz - v1.y)), (float)(centery - (v1.z + movez) * centerz / (centerz - v1.y)));
+ }
+
+ // Now we also draw the acceleration:
+// g2.setColor(Color.GREEN);
+// Vector v1 = new Vector(0,0,0);
+// Vector v2 = new Vector(accelx, accely, accelz);
+// v2.scale(20 * ginverse);
+// v1.setPosition();
+// v2.setPosition();
+// g2.draw(new Line2D.Double(
+// centerx + (v1.x + movex) * centerz / (centerz - v1.y),
+// centery - (v1.z + movez) * centerz / (centerz - v1.y),
+// centerx + (v2.x + movex) * centerz / (centerz - v2.y),
+// centery - (v2.z + movez) * centerz / (centerz - v2.y)));
}
@Override