Click here to Skip to main content
12,509,612 members (52,132 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

368.4K views
16K downloads
179 bookmarked
Posted

C# Avionic Instrument Controls

, 17 Jul 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
The aim of this C# project is to purpose six aircraft cockpit instruments usable in forms as any other C# controls.

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

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 its 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 detail the implementation of the basic functions defined in the InstrumentControl class.

Rotate Image

Implementation

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

First, the rotation of the PaintEventArgs coordinate system around the upper left corner of the drawing area.

Second, the drawing 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 apply the translation correction.

AvionicsControlDemo_RotationPhase2.JPG

Corresponding code sample:

// Display 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 explains 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 identify the G1G0 translation and apply 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

The corresponding code sample is as follows:

// 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)

Share

About the Author

Chootair
Engineer
France France
No Biography provided

You may also be interested in...

Pro
Pro

Comments and Discussions

 
QuestionExcellent Pin
Pablo Odysseus8-Jun-16 3:34
memberPablo Odysseus8-Jun-16 3:34 
Questioni love you my bro Pin
armanfx28-Mar-16 5:49
memberarmanfx28-Mar-16 5:49 
QuestionHow d I add this toolbox to my project? there is no .dll file. Pin
Member 118586067-Jan-16 3:54
memberMember 118586067-Jan-16 3:54 
GeneralMessage Removed Pin
Member 940141530-Dec-15 5:03
memberMember 940141530-Dec-15 5:03 
QuestionUpgraded altimeter Pin
Redgum20-Nov-14 10:58
memberRedgum20-Nov-14 10:58 
Question!Need Help in Creating a VB.NET Avionics Intsrument Control Pin
schematicsman7-Jan-14 1:30
memberschematicsman7-Jan-14 1:30 
QuestionHow to use these controls for an existing project Pin
Member 1016504020-Jul-13 11:15
memberMember 1016504020-Jul-13 11:15 
QuestionHow to add these controls to my project? Pin
Breaka18-Apr-13 15:34
memberBreaka18-Apr-13 15:34 
GeneralVery very nice Code Project sample... Pin
Destiny77718-Sep-12 8:35
memberDestiny77718-Sep-12 8:35 
QuestionAide Pin
bbjodel27-Jun-12 5:53
memberbbjodel27-Jun-12 5:53 
QuestionVery nice controls Pin
Mike Hankey15-Apr-12 0:30
memberMike Hankey15-Apr-12 0:30 
QuestionImport to VB.Net Pin
JTmetoo28-Aug-11 9:06
memberJTmetoo28-Aug-11 9:06 
QuestionGreat Job Pin
Lamar Seifuddin29-Jul-11 21:36
memberLamar Seifuddin29-Jul-11 21:36 
GeneralRe: Great Job Pin
Destiny77718-Sep-12 8:42
memberDestiny77718-Sep-12 8:42 
QuestionC# avionic controls Pin
JPC0624020-Jun-11 3:31
memberJPC0624020-Jun-11 3:31 
Generalthank you Pin
yardloun4-Apr-11 4:56
memberyardloun4-Apr-11 4:56 
GeneralMy vote of 5 Pin
YEBM Knight8-Feb-11 3:14
memberYEBM Knight8-Feb-11 3:14 
GeneralGreat work - I am using these with the AR Drone Pin
shobley17-Oct-10 6:52
membershobley17-Oct-10 6:52 
GeneralRe: Great work - I am using these with the AR Drone Pin
Destiny77718-Sep-12 8:43
memberDestiny77718-Sep-12 8:43 
Generali love the control I hope Pin
StringDotEmpty16-May-10 2:23
memberStringDotEmpty16-May-10 2:23 
GeneralWell done. Pin
Serhat20-Apr-10 20:47
memberSerhat20-Apr-10 20:47 
GeneralConnect up to FlightGear flight simulator Pin
steveyork28-Oct-09 6:25
membersteveyork28-Oct-09 6:25 
GeneralAdd to asp.net page Pin
girishdpatil24-Feb-09 20:09
membergirishdpatil24-Feb-09 20:09 
GeneralAdd to projects Pin
Frank Shearer20-Feb-09 14:28
memberFrank Shearer20-Feb-09 14:28 
GeneralRe: Add to projects Pin
alejos30-Mar-10 3:26
memberalejos30-Mar-10 3:26 
GeneralRe: Add to projects Pin
Serhat20-Apr-10 21:14
memberSerhat20-Apr-10 21:14 
GeneralRe: Add to projects Pin
Member 779617320-Apr-11 6:29
memberMember 779617320-Apr-11 6:29 
GeneralRe: Add to projects Pin
Member 779617320-Apr-11 11:30
memberMember 779617320-Apr-11 11:30 
GeneralTransform Pin
NicolasG25-Jul-08 10:59
memberNicolasG25-Jul-08 10:59 
GeneralRe: Transform Pin
DrGanjoo11-Nov-08 23:08
memberDrGanjoo11-Nov-08 23:08 
GeneralExcellent look and feel to these controls - well done Pin
BradOsterloo21-Jul-08 12:05
memberBradOsterloo21-Jul-08 12:05 
GeneralCool! Pin
bigals20-Jul-08 13:55
memberbigals20-Jul-08 13:55 
GeneralRe: Cool! Pin
Destiny7779-Oct-12 17:41
memberDestiny7779-Oct-12 17:41 
GeneralFantastic job.... But there is something missing... Pin
The Infomercial King18-Jul-08 7:11
memberThe Infomercial King18-Jul-08 7:11 
GeneralRe: Fantastic job.... But there is something missing... Pin
andre1234518-Jul-08 8:53
memberandre1234518-Jul-08 8:53 
GeneralRe: Fantastic job.... But there is something missing... Pin
The Infomercial King18-Jul-08 9:55
memberThe Infomercial King18-Jul-08 9:55 
GeneralRe: Fantastic job.... But there is something missing... Shudder? Pin
Destiny77718-Sep-12 8:46
memberDestiny77718-Sep-12 8:46 
GeneralRe: Fantastic job.... But there is something missing... Shudder? Pin
Bill SerGio, The Infomercial King18-Sep-12 10:14
memberBill SerGio, The Infomercial King18-Sep-12 10:14 
GeneralRe: Fantastic job.... But there is something missing... Shudder? Pin
Destiny7779-Oct-12 17:38
memberDestiny7779-Oct-12 17:38 
GeneralRe: Fantastic job.... But there is something missing... Shudder? Pin
Bill SerGio, The Infomercial King10-Oct-12 1:05
memberBill SerGio, The Infomercial King10-Oct-12 1:05 
GeneralRe: Fantastic job.... But there is something missing... Shudder? Pin
Destiny77730-Dec-12 21:39
memberDestiny77730-Dec-12 21:39 
GeneralAH for 90 degree pitch Pin
jknickel8-Jul-08 0:24
memberjknickel8-Jul-08 0:24 
GeneralRe: AH for 90 degree pitch Pin
Chootair17-Jul-08 11:59
memberChootair17-Jul-08 11:59 
GeneralGreat stuff Pin
jknickel7-Jul-08 22:54
memberjknickel7-Jul-08 22:54 
GeneralSuperb but... Pin
Joe Sonderegger7-Jul-08 22:01
memberJoe Sonderegger7-Jul-08 22:01 
GeneralGreat work.... Pin
Peter Villadsen7-Jul-08 14:33
memberPeter Villadsen7-Jul-08 14:33 
GeneralRe: Great work.... Pin
Chootair17-Jul-08 12:03
memberChootair17-Jul-08 12:03 
JokeImpressive Pin
Ivertheengine7-Jul-08 9:32
memberIvertheengine7-Jul-08 9:32 
GeneralWow! Pin
Rafferty Uy3-Jul-08 15:48
memberRafferty Uy3-Jul-08 15:48 
GeneralVery nice indeed. Question... Pin
thompsons2-Jul-08 6:42
memberthompsons2-Jul-08 6:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160929.1 | Last Updated 17 Jul 2008
Article Copyright 2008 by Chootair
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid