Jump to content
Sign in to follow this  
n4gix

Xml - Calculating Vertical Profile Angle

Recommended Posts

I'm embarrased to admit that my trig skills have long since vanished (if indeed they ever existed!)... so here I am, hat in hand again. :( I need to calculate the theta of a right triangle. I know the length of the opposite and the adjacent sides:b = opposite side = (A:AUTOPILOT ALTITUDE LOCK VAR,feet) (A:Indicated Altitude,feet) -a = adjacent side = (@c:FlightPlanWaypointRemainingDistance,feet)calculateanglerighttriawb6.jpgUnless my memory has totally failed, this is the formula needed:tan(theta) = b / a If this is accurate, what would the XML syntax for this formula be???The SDK states: tg Tangent (input in radians) This script produces garbage... :(

			<Element Name="Vertical Profile">				<Position X="166" Y="668"/>				<Polyline LineWidth="3" Color="White" Bright="Yes">					<Axis X="0" Y="0"/>					<Point X="0" Y="0"/>					<Point X="160" Y="0"/>				</Polyline>				<Rotate>					<Value Minimum="-90" Maximum="90">						(@c:FlightPlanWaypointRemainingDistance,feet) (A:AUTOPILOT ALTITUDE LOCK VAR,feet) (A:Indicated Altitude,feet) - / dgrd tg /-/					</Value>				</Rotate>				<Shift>					<Value Minimim="0" Maximum="24000">						(A:Indicated Altitude,feet)					</Value>					<Scale Y="-0.0055"/>				</Shift>											</Element>


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
I'm embarrased to admit that my trig skills have long since vanished (if indeed they ever existed!)... so here I am, hat in hand again. :blush: I need to calculate the theta of a right triangle. I know the length of the opposite and the adjacent sides:b = opposite side = (A:AUTOPILOT ALTITUDE LOCK VAR,feet) (A:Indicated Altitude,feet) -a = adjacent side = (@c:FlightPlanWaypointRemainingDistance,feet)calculateanglerighttriawb6.jpgUnless my memory has totally failed, this is the formula needed:tan(theta) = b / a If this is accurate, what would the XML syntax for this formula be???The SDK states: tg Tangent (input in radians) This script produces garbage... :blush:
			<Element Name="Vertical Profile">				<Position X="166" Y="668"/>				<Polyline LineWidth="3" Color="White" Bright="Yes">					<Axis X="0" Y="0"/>					<Point X="0" Y="0"/>					<Point X="160" Y="0"/>				</Polyline>				<Rotate>					<Value Minimum="-90" Maximum="90">						(@c:FlightPlanWaypointRemainingDistance,feet) (A:AUTOPILOT ALTITUDE LOCK VAR,feet) (A:Indicated Altitude,feet) - / dgrd tg /-/					</Value>				</Rotate>				<Shift>					<Value Minimim="0" Maximum="24000">						(A:Indicated Altitude,feet)					</Value>					<Scale Y="-0.0055"/>				</Shift>											</Element>

I use Indicated Altitude, feet FlightPlanDestinationAltitude,feet - distance remaing nmiles 6076.13 * / tg rddg = Vertical bearing in degrees

Paul EGLD

Share this post


Link to post
Share on other sites

Fr. Bill,This works somehow:<Element Name="Vertical Profile"><Position X="60" Y="360"/><Polyline LineWidth="3" Color="White" Bright="Yes"><Axis X="0" Y="0"/><Point X="0" Y="0"/><Point X="160" Y="0"/></Polyline><Rotate><Value Minimum="-90" Maximum="90">(A:AUTOPILOT ALTITUDE LOCK VAR,feet) (A:Indicated Altitude,feet) - (@c:FlightPlanWaypointRemainingDistance,feet) / tg rddg -1 * </Value></Rotate><Shift><Value Minimim="0" Maximum="32000">(A:Indicated Altitude,feet)</Value><Scale Y="-0.01"/></Shift> </Element>Of course not knowing what you are exactly up to.Jan

Share this post


Link to post
Share on other sites
Fr. Bill,This works somehow:
Thanks! I only had to make one tiny correction to properly scale the output to my display:(A:AUTOPILOT ALTITUDE LOCK VAR,feet) (A:Indicated Altitude,feet) - (@c:FlightPlanWaypointRemainingDistance,feet) / tg rddg -0.1 *

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
I use Indicated Altitude, feet FlightPlanDestinationAltitude,feet - distance remaing nmiles 6076.13 * / tg rddg = Vertical bearing in degrees
Thanks for the reply. That will work fine providing that the flightplan has a "planned altitude" for specific waypoints. AFAIK, default FS flightplans do not have such information available...

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
I need to calculate the theta of a right triangle. I know the length of the opposite and the adjacent sides:b = opposite side = (A:AUTOPILOT ALTITUDE LOCK VAR,feet) (A:Indicated Altitude,feet) -a = adjacent side = (@c:FlightPlanWaypointRemainingDistance,feet)Unless my memory has totally failed, this is the formula needed:tan(theta) = b / a If this is accurate, what would the XML syntax for this formula be???
Bill, unless I am very out of trigs, the correct formula should be:theta = arctan( b / a )I see in previous posts that you are doing (value1,feet) (value2,feet) / tg rddg , but (value1,feet) (value2,feet) / gives a number, so you are actually calculating the tangent of a number where you should be calculating the tangent of an angle. :( Instead, I think you should use (value1,feet) (value2,feet) / atg rddg; atg is the arctangent of a number that returns its corresponding arc-angle- in radians, which you convert to degrees with rddg.I've used atg in some of my gauges (a steering tiller for example) and works fine.Tom

Share this post


Link to post
Share on other sites
Bill, unless I am very out of trigs, the correct formula should be:theta = arctan( b / a )I see in previous posts that you are doing (value1,feet) (value2,feet) / tg rddg , but (value1,feet) (value2,feet) / gives a number, so you are actually calculating the tangent of a number where you should be calculating the tangent of an angle. :( Instead, I think you should use (value1,feet) (value2,feet) / atg rddg; atg is the arctangent of a number that returns its corresponding arc-angle- in radians, which you convert to degrees with rddg.I've used atg in some of my gauges (a steering tiller for example) and works fine.Tom
Oddly enough, there's no difference in the end result whether I use tg or atg in the formula... :( I have a sinking feeling that I'm not going to be able to accomplish my final goal via XML for the V Profile. Here is a V Profile drawn in GDI+ for a Honeywell Primus 2000 MFD. I'm trying to implement something similar using XML and I don't think it will be possible since there's no way to dynamically change the x,y coordinates... :( rmu850000026aj1.jpg

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Can you draw vector lines by calculated x/y values?


Ed Wilson

Mindstar Aviation
My Playland - I69

Share this post


Link to post
Share on other sites
Oddly enough, there's no difference in the end result whether I use tg or atg in the formula... B)
Oh yes, there is quite a difference :( The reason you don't see it clearly is because you're testing with small angles (1-10 degrees), where the values are almost the same because of tg/atg expressed in radians. But as long as both sides of the triangle (altitude/distance) approach to the same size, using tg will tend to show a +-90 deg angle, and using atg will do the same towards +-45 deg angle which would be the correct one.
I have a sinking feeling that I'm not going to be able to accomplish my final goal via XML for the V Profile. Here is a V Profile drawn in GDI+ for a Honeywell Primus 2000 MFD. I'm trying to implement something similar using XML and I don't think it will be possible since there's no way to dynamically change the x,y coordinates... :( rmu850000026aj1.jpg
Well, I might agree with you here. Despite it would be technically possible to draw the V profile in XML, the lack of dynamical change in X,Y coordinates would make it a complex and tedious task.. :( Tom

Share this post


Link to post
Share on other sites
Can you draw vector lines by calculated x/y values?
No, as I stated previously. That's because x,y coordinate pairs are passed the to the XML parsing engine as string instead of integer or float values... ...which is idiotic since the XML parsing engine converts the string data to floats for the C/GDI rendering engine... :(

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Oh yes, there is quite a difference :( Well, I might agree with you here. Despite it would be technically possible to draw the V profile in XML, the lack of dynamical change in X,Y coordinates would make it a complex and tedious task.. :( Tom
Yeah, after I did a bit more testing I realized that your observation is correct.The company that commissioned this project aren't paying nearly enough to support that amount of effort, so I've opted drawing a single "leg" at a time rather than the complete flightplan......which is why I need to use a calculated angle for the single v-path vector... B) What makes this display more challenging (as if it weren't enough challenge already!) is that, unlike the Primus 2000 V-Path display, in this design the a/c symbol "rises up" to the target altitude, with the vertical scale on the left side "rising also" when > FL240, and the horizontal scale changes in response to the selected "range" of the ND display! :(

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...