Drawing a Line with an Angle.

Drawing a Line with an Angle.

Post by none » Sat, 08 Apr 2000 04:00:00



Hi All, is there a way to draw a line with a angle value?

Here is what i've gotten so far but haven't been able to get it to work.

Thanks for any and all advice..

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
  CenterX, CenterY, VectX, VectY: integer;
  X1: integer;
  DX,DY,Angle,Dis:Real;
  Cx,Cy,Xd,Yd:Real;
begin
  Cx:=ClientWidth div 2;Cy:=ClientHeight div 2;
  Xd := Cx-X;
  Yd := Cy-Y;
  Dis := ARCTAN2(Yd, Xd);
  Dx := Cos(Dis*Pi/180);
  Dy := Sin(Dis*Pi/180);
  For X:= 0 to 100 do
  begin
  Cx:=Cx-Dx;Cy:=Cy-Dy;
  Form1.Canvas.Pixels[Round(Cx),Round(Cy)]:=clwhite;
  end;
end;

 
 
 

Drawing a Line with an Angle.

Post by Rene Tschaggela » Sun, 09 Apr 2000 04:00:00


You want to draw non horizontal line ?

How about :
 image1.canvas.pen.color:=clbalck;
 image1.canvas.moveto(x1,y1);
 image1.canvas.lineto(x2,y2);

If you don't want to use the line proc, I have an algorithm on
one of my delphi pages.

Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com

 
 
 

Drawing a Line with an Angle.

Post by Earl F. Glyn » Sun, 09 Apr 2000 04:00:00



> Hi All, is there a way to draw a line with a angle value?

Assume you're at the point (X1,Y1) and want to draw a line of
a given length (R) at a specified angle (theta) with the X-axis.

The second point,  (X2,Y2), on the line would be:

X2 = X1 + R*COS(theta)
Y2 = Y1 + R*SIN(theta)

Remember that theta needs to be in Radians.  You can use the
math library routine DegToRad to convert Degrees to Radians.
You will also need to use TRUNC or ROUND, e.g.,
ROUND(R*COS(theta)), since the trig computations involve
floating point.

The points [ R*COS(theta), R*SIN(theta) ] would give you
points around a circle of radius R as a function of theta.

--
efg


Overland Park, KS  USA

efg's Computer Lab:  http://www.efg2.com/Lab

 
 
 

Drawing a Line with an Angle.

Post by Norb Ecker » Fri, 28 Apr 2000 04:00:00


How can you set the origin point (0,0) from the upper left corner of the
TImage to the lower right corner?  Such that positive x-values increase to
the left and positive y-values increase upward like a normal coordinate
system.

I am trying to plot an image and it is displayed upside down, not to mention
the scale is completely off.  I am able to do this in Visual Basic using a
Picture control with a minimum of fuss.

TIA,

Norb

Quote:> You want to draw non horizontal line ?

> How about :
>  image1.canvas.pen.color:=clbalck;
>  image1.canvas.moveto(x1,y1);
>  image1.canvas.lineto(x2,y2);

> If you don't want to use the line proc, I have an algorithm on
> one of my delphi pages.

> Rene
> --
> Ing.Buero R.Tschaggelar - http://www.ibrtses.com

 
 
 

1. SnappyLine -- Draw Lines with Text Label at Any Angle

Gordon Whittam contributed a very interesting "Snappy Line" project to my Computer Lab.

With the SnappyLine program you can draw "free" lines, which are lines that snap to each other and measure angles.  Lines can be
highlighted with a trackbar and erased when the trackbar is released. SnappyLine also demonstrates the creation of a LogFont for
drawing the text dimensions at any angle.

Take a look at the Snappy Line Lab Report at
www.efg2.com/lab/Graphics/SnappyLine.htm

efg
_________________________________
efg's Computer Lab:       www.efg2.com/lab
Delphi Books:  www.efg2.com/lab/TechBooks/Delphi.htm


Overland Park, KS  USA

2. PDF Files

3. Adding colour to scanned line drawings for CMYK printing Adding colour to scanned line drawings for CMYK printing Adding colour to scanned line drawings for CMYK printing

4. corel draw 8 where can i find it

5. Drawing different line types at different line width

6. Help: Displaying 256 Colors

7. Draw polygon face and line in one line

8. Is there a version of gnuplot for the mac?

9. Drawing non solid line with line width greater than one

10. HELP: Line drawing routine does not draw right.

11. ati radeon 8500 (line drawing and point drawing)

12. angle between two lines

13. Angles of a line?