|Delphi Graphics: Algorithms|
|2D/3D||GraphicsMathPrimitives. 2D/3D Clipping, 3D-to-2D Projections.
See 2D/3D vector graphics examples on efg's Graphics projects page.
Math; // ArcTan2
// Given points(iText,jText) and (iTarget,jTarget). The angle
The TCanvas.Arc method is is not that easy to use for some applications. The DrawArcs demo shows how to define a bounding rectangle and then draw the specified type of arc between opposite corners of the rectangle.
BoundRect := Rect(xMin,yMin, xMax,yMax);
efg's Polygon Area and Centroid Lab Report
TriangleArea and TriangleHeight functions in William Egge's EMath unit
|Aspect Ratio||efg's Aspect Ratio Lab Report|
|Axes||For an explanation of the following diagram,
see the Discussion
section of the Basketball Lab
See efg's MapWorldToPixel unit for a quick way to map (x,y) to (i,j).
Dave Shapiro's UseNet Post explaining "Why is 'y' upside down?" (or how to make the y-axis increase from bottom-to-top instead of top-to-bottom)
See GraphicsMath (below) for Pantograph objects that perform this mapping for 2D/3D vectors, along with projections and clipping.
"Windows 95/98 uses a 16-bit world coordinate system and restricts x- and y- coordinates for text and graphics to the range ±32K. Windows NT/Windows 2000 uses a 32-bit world coordinate system and allows coordinates in the range ±2 gigabytes (GB). If you pass full 32-bit coordinates to text and graphics functions in Windows 95/98, the system truncates the upper 16 bits of the coordinates before carrying out the requested operation."
"Because Windows 95/98 uses a 16-bit coordinate system, the sum of the coordinates of the bounding rectangle specified by the Arc, Chord, Pie, Ellipse, and RoundRect functions cannot exceed 32K. In addition, the sum of the nLeftRect and nRightRect parameters or the nTopRect and nBottomRect parameters cannot exceed 32K.""
[Of course Microsoft broke the link with this information so the original MSDN reference in no longer available.]
|Bézier Curve||Boris Novgorodov's UseNet
Post with PolyBezier example
Jean-Yves Queinec's Bézier project
Béziers and Paths by Clinton R. Johnson
Alexander Weidauer's UseNet Post
showing a "function to draw a Bézier curve starting from a
The "Bezier Draw" is a sample Delphi program to demonstrate the
use of "Bezier" unit.
See PolyBezier API call
|Charts||See Charts and Graphs on efg's Delphi Graphics Components and Programs page|
|Circles||How to determine the circle through three given
points: efg's UseNet
Post1 and Post2
Division of Semicircle into 2N Intervals Using
Half-Angle Formula and Rotation Formula
See "Circle Approximation" as part of Polygon Area and Centroid Lab Report
efg's UseNet Post about computing great circle distances
|Coordinate Systems||Tomes Graphical, pp. 13-19|
|Contours & Isosurfaces||http://huizen.dto.tudelft.nl/deBruijn/programs/suna55.htm
MUMIL - a cursor based contouring routine
|Cubic Curve||Lorc CRC's UseNet Post with DrawCubicCurve example|
|Curves and Surfaces||Non-Delphi site (in French):
COURBES ET SURFACES MATHEMATIQUES
|Distance||Distance from point P1(x1, y1) to P2(x2, y2):
SQRT( SQR(x1-x2) + SQR(y1-y2) ), or using a function from the math unit:
Distance from point P1(x1, y1) to Line, a*x + b*y + c = 0
DistPoint2Line and DistPoint2LineSegment functions in William Egge's EMath unit
|Ellipsoid||efg's UseNet Post with comments about how to draw an ellipsoid as a series of elliptical "slices"|
|Floating-Point Math||Non-Delphi: "Floating-Point for Real-Time 3D," Chapter 63, Michael Abrash's Graphics Programming Black Book (out of print)|
|Fractals|| efg's Fractals and Chaos page
Using a background thread to compute and display a Mandelbrot set using HSVcolor scheme, Delphi in a Nutshell, pp. 148-151
Borland's Fractal Generator Contest
Chapter 6, "3D Fractal Landscapes" in Kick Ass Delphi
Programming (out of print)
|Geometric Figure||Line Art on a TImage. This example draws lines on a
TImage resulting in this geometric figure.
Geometry Library, Geometry.ZIP. This unit contains
types, functions and procedures for quaternion, vector and matrix arithmetics. It is
specifically designed for geometric calculations within R3 ("affine" vector
space) and R4 (homogeneous vector space).
|Graphics Math||efg's GraphicsMathLibrary
unit for Matrix/Vector Operations for 2D/3D Graphics using Homogeneous
Coordinates. Includes conversion between coordinate systems (Cartesian,
polar, spherical), matrix transforms (translation, rotation, scaling), and
a ViewTransformMatrix routine to compute how world coordinates
should be transformed for plotting from a given camera/eye location.
efg's GraphicsPrimitivesLibrary unit (uses GraphicsMathLibrary unit) defines a TPantoGraph class. A TPantoGraph object maps 2D/3D "World Coordinates" to a Delphi "Canvas". These World Coordinates are DOUBLE values that are defined using regular mathematical conventions. This means that instead of having increasing "Y" values as you go down a canvas, "Y" increases as you go up using the computer "pantograph". Includes clipping and various projection options.
Suggestion by CC.Campbell for using TextOut with TPantograph
|Graphs||See Charts and Graphs on efg's Delphi Graphics Components and Programs page|
|Hex Grid||John McDonnell's UseNet Post about drawing a hex grid|
|Homogeneous Coordinates: Scaling, Rotation, Translation||[Foley96, pp.
efg's TPantograph in Football, Sphere In Cube, or other Lab Reports
|Maps, Cartography||See Maps on Delphi Graphics Algorithms page|
|Mathematics for Computer Graphics||[Foley96, Appendix, pp. 1083-1112]|
|Matrix Transformations||GraphicsMathLibrary. 2D/3D matrices for translation, scaling,
rotation of homogeneous coordinates.ViewTransformMatrix. Part of any of the 2D/3D vector
graphics examples on efg's Graphics page.
Matrices (and 3D graphics) www.geocities.com/SiliconValley/2151/matrices.html (Non-Delphi)
|Moiré Patterns||efg's Daisy Lab Report|
|Numeric Data to Bitmap||
How to create a Bitmap from numeric data? (D5)
Read TXT file into dynamically allocated matrix and show matrix as either gray scale or "rainbow" values:
(A "LargeMatrix" program is included to create large test matrices. A 1200-by-900 matrix will take about 5 minutes on a 650 MHz Pentium III.)
|Perimeter||efg's E-mail to Engineering Student at kmutt about how to computer perimeter of an object|
Michael Hansen's Perlin Noise project
|Pi||efg's Lab Report: Estimate value of pi using Buffon's "needles"|
|Point in Polygon||Mat Ballard's UseNet
Post with PointInPolygonTest function
adub's UseNet Post with PtInPolygon using PtInRegion WinAPI call
Paul Nicholls' UseNet Post with point-in-polygon routine
John Hutchings' UseNet Post with PointInPolygonTest function
// InSide function by Andreas Filsinger
Also see PtInRegion on Graphical Win32 API page
|Point in Triangle||Dave Eberly's UseNet Post:
Let the points be
(x0,y0,z0), (x1,y1,z1), (x2,y2,z2). Given (x,y), solve for s and t in (x,y) =
(x0,y0)+s*(x1-x0,y1-y0)+t*(x2-x0,y2-y0). The point is inside the triangle if s >=
0, t >= 0, and s+t <= 1. Then choose z = (1-s-t)*z0+s*z1+t*z2.
efg's Maxwell Triangle Lab Report
|Point on Line||Schoeneck Howell's UseNet
Post with pointonline function
efg's Line Stretch Lab Report with NearLine function
|Points, Angles||Calculating a point using angles and distance (FAQ 2915D)
Calculating an angle from two points (and the origin) (FAQ 1917D)
Finding distance between two points (FAQ 2928D)
|Polygons||Non-Delphi: Michael Abrash's Graphics Programming Black Book, Chapter 39, "Fast Convex Polygons"|
|Projections||D3toD2 and D2toD3 functions in William Egge's EMath unit|
|Rectangles||Rectangles: A Closer Look at the TRect Windows Data Type. (CopyRect, InflateRect, IntersectRect, IsRectEmpty, OffsetREct, Rect, SetRect, SetRectEmpty, SubtractRect, UnionRect, ScreenToClient, ClientToScreen, pRect, ClipCursor), Delphi Informant, Aug. 1999.|
|Splines||Splines by Charles Hacker
BSplines.ZIP by Martijn an Engeland. Component for handling and displaying BSplines. Delphi Super Page: http://delphi.icm.edu.pl/ftp/d10free/bsplines.zip
[Foley96, pp. 1013-1018]
|Surfaces||Surface Plot Collection. Components that know how to
plot surfaces given by formulas. Contains a component for (plain cartesian) graphs and one
for parametric surfaces
|TMathImage||A TGraphicControl descendant that allows drawing in world
coordinates. Both 2-D and 3-D graphs are supported. Surfaces can be drawn filled with
hidden invisible parts and
The "Twirl" program is based on the spiral transform from Beyond Photography: The Digital Darkroom (the book is online) by Gerard J. Holzmann, Prentice-Hall, 1988, pp. 44-45. The book gives the formula for transforming a picture of Ken Thompson (one of the originators of UNIX):
new[radius, angle] = ken[radius, angle + radius/3]
Twist.ZIP (D3-D5 complete project with source code -- BMPs not included)
|Transformation, Affine and Projective||Example code by Lazikas o Pontios for Intergraph Irasc files.|
|Vector Graphics||Simple Vector Library
Foley96 (referenced above in several places) is not a Delphi book,
but is an excellent source for computer graphics algorithms.
Links Verified 11 Feb 2003
Updated 26 Feb 2005
since 6 Feb 2000