#### Archived

This topic is now archived and is closed to further replies.

# 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)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???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>`

##### Share on other sites
 Help AVSIM continue to serve you!Please donate today!
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)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???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>`

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

##### 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 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 *

##### 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...

##### 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 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... :(

##### Share on other sites

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

##### 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... :(
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 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... :(

##### 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! :(

##### Share on other sites

• Tom Allensworth,
Founder of AVSIM Online

• ### Hot Spots

• 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!