Click here to Skip to main content
6,594,432 members and growing! (14,027 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » Custom Controls     Beginner License: The Code Project Open License (CPOL)

C# avionic instrument controls

By Chootair

The aim of this C# project is to purpose six aircraft cockpit instruments usable in forms as any other C# controls
C# (C# 2.0), .NET (.NET 2.0)
Posted:1 Jul 2008
Updated:17 Jul 2008
Views:30,661
Bookmarked:85 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
29 votes for this article.
Popularity: 6.75 Rating: 4.62 out of 5
1 vote, 3.4%
1

2
1 vote, 3.4%
3
4 votes, 13.8%
4
23 votes, 79.3%
5

Introduction

The aim of this C# project is to purpose six aircraft cockpit instruments usable in forms as any other C# controls and to define a generic instrument class in order to design any kind of dashboard instuments.

Description

The controls are built with bitmaps which are rotated, translated or scaled before to be displayed. The basic methods for rotate, translate and scale images are defined in the mother class. Each control then uses his dedicated parameters (related to a physical signification) in order to manipulates the images .

Aircraft instruments

Air speed indicator : airspeed (kts)

Attitude Indicator : pitch (deg), roll (deg)

Altimeter : altitude (ft)

Turn Coordinator : turn rate (deg/min)

Vertical speed indicator : vertical speed (ft/min)

Heading indicator : heading (deg)

Details of the key functions

This section explains in details the implementation of the basic functions defined in the InstrumentControl class.

Rotate Image

Implementation

The rotation of the image is divided in two main part:

First : the rotation of the PaintEventArgs coordinate system around the upper left corner of the drowing area.

Second : the drowing of the image corrected by translation offset in order to display the image as if it has turned around a user defined point

AvionicsControlDemo_RotationMainSteps.JPG

Let’s see step by step

Step 0 : initial situation.

AvionicsControlDemo_RotationPhase0.JPG

Step 1 : Rotate the PaintEventArgs coordinate system around the left upper corner of the paint area.

AvionicsControlDemo_RotationPhase1.JPG

Corresponding code sample:

// Rotate image support
pe.Graphics.RotateTransform((float)(alpha * 180 / Math.PI));
 

Step 2 Draw the image and applies the translation correction.

AvionicsControlDemo_RotationPhase2.JPG

Corresponding code sample :

// Dispay image
pe.Graphics.DrawImage(img, (ptImg.X + deltaX) * scaleFactor, (ptImg.Y + deltaY) * scaleFactor, img.Width * scaleFactor, img.Height * scaleFactor); 

Step 3 (Final step ) : Put the PainEventArgs coordinate system as found.

AvionicsControlDemo_RotationPhase3.JPG

Corresponding code sample :

// Put image support as found
pe.Graphics.RotateTransform((float)(-alpha * 180 / Math.PI));


The key point in those operations is the calculation of the translation correction coefficients.

The next figure explain the geometrics considerations.

AvionicsControlDemo_RotationDetailedScheme.JPG

G0 is the user defined rotation center
G1 is the G0 position after the step 1.

The aim of this section is to identified the G1G0 translation and applied the corresponding offset in order to draw the rotation point as if it has not moved.

Then we work with the geometrics definitions:

a)

AvionicsControlDemo_RotationCalcs1.JPG

b)

AvionicsControlDemo_RotationCalcs2.JPG

c)

AvionicsControlDemo_RotationCalcs3.JPG

d)

AvionicsControlDemo_RotationCalcs4.JPG

As a result the offset coefficients are :

AvionicsControlDemo_RotationCalcs5.JPG


Corresponding code sample :

  // Computed offset
deltaX = (float)(d * (Math.Cos(alpha - beta) - Math.Cos(alpha)* Math.Cos(alpha + beta) - Math.Sin(alpha) * Math.Sin(alpha+ beta)));
deltaY = (float)(d * (Math.Sin(beta - alpha) + Math.Sin(alpha)* Math.Cos(alpha + beta) - Math.Cos(alpha) * Math.Sin(alpha + beta)));

Parameters


"pe" :The paint area event where the image will be displayed
"img" :The image to display
"alpha" :The angle of rotation in radian
"ptImg" :The location of the left upper corner of the image to display in the paint area in nominal situation
"ptRot" :The location of the rotation point in the paint area
"scaleFactor" : Multiplication factor on the display image

AvionicsControlDemo_RotationFunctionParameters.JPG

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Chootair


Member

Occupation: Engineer
Location: France France

Other popular Miscellaneous articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 24 of 24 (Total in Forum: 24) (Refresh)FirstPrevNext
GeneralConnect up to FlightGear flight simulator Pinmembersteveyork7:25 28 Oct '09  
GeneralAdd to asp.net page Pinmembergirishdpatil21:09 24 Feb '09  
GeneralAdd to projects PinmemberFrank Shearer15:28 20 Feb '09  
GeneralTransform PinmemberNicolasG11:59 25 Jul '08  
GeneralRe: Transform PinmemberDrGanjoo0:08 12 Nov '08  
GeneralExcellent look and feel to these controls - well done PinmemberBradOsterloo13:05 21 Jul '08  
GeneralCool! Pinmemberbigals14:55 20 Jul '08  
GeneralFantastic job.... But there is something missing... PinmemberThe Infomercial King8:11 18 Jul '08  
GeneralRe: Fantastic job.... But there is something missing... Pinmemberandre123459:53 18 Jul '08  
GeneralRe: Fantastic job.... But there is something missing... PinmemberThe Infomercial King10:55 18 Jul '08  
GeneralAH for 90 degree pitch Pinmemberjknickel1:24 8 Jul '08  
GeneralRe: AH for 90 degree pitch PinmemberChootair12:59 17 Jul '08  
GeneralGreat stuff Pinmemberjknickel23:54 7 Jul '08  
GeneralSuperb but... PinmemberJoe Sonderegger23:01 7 Jul '08  
GeneralGreat work.... PinmemberPeter Villadsen15:33 7 Jul '08  
GeneralRe: Great work.... PinmemberChootair13:03 17 Jul '08  
JokeImpressive PinmemberIvertheengine10:32 7 Jul '08  
GeneralWow! PinmemberRafferty Uy16:48 3 Jul '08  
GeneralVery nice indeed. Question... Pinmemberthompsons7:42 2 Jul '08  
GeneralVery Good PinmemberJBAK_CP4:41 2 Jul '08  
GeneralRemarkable! PinmemberLastZolex0:15 2 Jul '08  
GeneralExcellento! PinmemberTage Lejon22:08 1 Jul '08  
GeneralThis could be very cool PinmemberBert delaVega18:28 1 Jul '08  
GeneralAlitmeter Pinmembersgenie6815:17 1 Jul '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 17 Jul 2008
Editor:
Copyright 2008 by Chootair
Everything else Copyright © CodeProject, 1999-2009
Web15 | Advertise on the Code Project