2013-07-26 10 views
1

그래서 Windows Phone 용 가로 모드 롤에서 각도를 계산 어떻게, 나는 결합 된 모션 (http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202984(v=vs.105).aspx)를 사용하여 내 응용 프로그램의 경우 윈도우 폰 8 용 센서 API를 테스트했습니다. 세로 모드에서, 나는 도로 (나는 요와 피치를 건너) 롤 매개 변수를 변환하면서내가 8

모든 것이 잘 작동, 나는 화면에도 단위의 각도를 인쇄 할 수 있습니다. 내가 전화를 잡고 시계 반대 방향으로 돌리면 각도가 0에서 -20, -30까지 올라가는 것을 볼 수 있습니다.

그러나 가로 모드로 전환하면 각도가 잘못 표시됩니다. 편주, 피치 및 롤 (읽기 : 비행기) 및 휴대 전화 (안드로이드, WP)에 적용되는 방법에 대해 조금 읽은 후에 롤 각도가 범위 [ -90,90]도. 롤 값을 출력 한 후에는 범위를 확인하는 것으로 보입니다 (이미지를 표시 할 수있는 탭 링크)

그래서 롤은 45도와 -135도를 구별 할 수 없습니다. 가치는 동일합니다.

는 그래서, 내 질문은 : 내가 무엇을 시계 방향 (또는 반 시계 방향) 돌리면 내가 (0-360에서) 절대 각도를 인쇄 할 내 애플 리케이션을하려면 어떻게해야합니까?

확실히 (가로 모드에서) 전화가 바닥과 평행하게 유지되는지 확인해야합니까?

VS2012/C#/Windows Phone 8 SDK를 사용하고 있습니다.

옳은 방향의 포인터는 고맙습니다. 아마도 고등학교 수학을 다듬을 필요가 있을까요?

+0

이 문제에 대한 해결책을 생각해 보셨습니까? – Hyndrix

+0

예, MS의이 스타터 키트를 살펴보십시오. http://xbox.create.msdn.com/en-us/education/catalog/sample/level_starter_kit – blooksa

답변

0

세로/가로 방향을 확인하려면 페이지에서 OrientationChanged 이벤트를 사용할 수 있습니다.

첫 페이지 초기화에서 방향을 결정 :

private PageOrientation lastOrientation; 

// Constructor 
public MainPage() 
{ 
    InitializeComponent(); 

    lastOrientation = this.Orientation; 

    if ((lastOrientation == PageOrientation.Landscape) || 
     (lastOrientation == PageOrientation.LandscapeLeft) || 
     (lastOrientation == PageOrientation.LandscapeRight)) 
    { 
     DoLandscapeCalculation(); 
    } 
    else if ((lastOrientation == PageOrientation.Portrait) || 
      (lastOrientation == PageOrientation.PortraitDown) || 
      (lastOrientation == PageOrientation.PortraitUp)) 
    { 
     DoPortraitCalculation(); 
    } 

    ... 

는 그 다음 OrientationChanged 이벤트에 등록하고 그에 따라 행동 :

private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e) 
{ 

    if ((e.Orientation == PageOrientation.Landscape) || 
     (e.Orientation == PageOrientation.LandscapeLeft) || 
     (e.Orientation == PageOrientation.LandscapeRight)) 
    { 
     //Landscape 
     DoLandscapeCalculation(); 
    } 
    else if ((e.Orientation == PageOrientation.Portrait) || 
      (e.Orientation == PageOrientation.PortraitUp) || 
      (e.Orientation == PageOrientation.PortraitDown)) 
    { 
     //Portrait 
     DoPortraitCalculation(); 
    } 

    // Extra work here! 

    ... 

    lastOrientation = e.Orientation; 
} 

희망이 당신을위한 시작이다.

감사합니다.

+0

감사의 마음을 전합니다. 나는 오리엔테이션 이벤트에 대해 잘 알고 있습니다. 내 질문은 DoPortraitCalculation() 및 DoLandscapeCalculation()이라고하는 메서드의 내용과 관련이 있습니다. Motion API에서 얻은 롤 값은 오리엔테이션과 상관없이 변경되지 않습니다. – blooksa