Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

Polygon-Calculator

Determine Polygon coordinates or Render OpenGL Graphics to Bitmap Frames.

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

Polygon-Calculator:

</br>

Compiler 10 Seattle 10 1 Berlin 10 2 Tokyo 10 3 Rio 10 4 Sydney 11 Alexandria 12 Athens
Components None

</br>

In geometry, a polygon is a plane figure made up of line segments connected to form a closed polygonal chain.

The segments of a closed polygonal chain are called its edges or sides. The points where two edges meet are the polygon's vertices or corners. An n-gon is a polygon with n sides; for example, a triangle is a 3-gon.

A simple polygon is one which does not intersect itself. More precisely, the only allowed intersections among the line segments that make up the polygon are the shared endpoints of consecutive segments in the polygonal chain. A simple polygon is the boundary of a region of the plane that is called a solid polygon. The interior of a solid polygon is its body, also known as a polygonal region or polygonal area. In contexts where one is concerned only with simple and solid polygons, a polygon may refer only to a simple polygon or to a solid polygon.

Features:

  • Get Polygon coordinates (Points, Areas)
  • Render OpenGL Graphic to Bitmap
  • Render Animate OpenGL Graphic to Bitmap Frames
  • Render differenet Pixel Bit
  • Control OpenGL Graphic Axis

</br>

</br>

Points:

Any polygon has as many corners as it has sides. Each corner has several angles. The two most important ones are:

  • Interior angle – The sum of the interior angles of a simple n-gon is (n − 2) × π radians or (n − 2) × 180 degrees. This is because any simple n-gon ( having n sides ) can be considered to be made up of (n − 2) triangles, each of which has an angle sum of π radians or 180 degrees.

Areas:

  • The signed area depends on the ordering of the vertices and of the orientation of the plane. Commonly, the positive orientation is defined by the (counterclockwise) rotation that maps the positive x-axis to the positive y-axis. If the vertices are ordered counterclockwise (that is, according to positive orientation), the signed area is positive; otherwise, it is negative. In either case, the area formula is correct in absolute value. This is commonly called the shoelace formula or surveyor's formula.

Code Example:

pascal
procedure ppyload;
var ms1: TResourcestream;
    i:integer;
    ww:real;
begin
   ms1 := TResourceStream.Create(hinstance,'x'+inttostr(nr),'RT_RCDATA');
    try
      ms1.readbuffer(ppy,ms1.size);
      pzahl:=(ms1.size-2) div 12;
  finally
    ms1.Free;
  end;
  ppx:=@ppy;
  smax:=0;
  for i:=0 to pzahl-1 do begin
    ww:=sqr(ppx[i,0])+sqr(ppx[i,1])+sqr(ppx[i,2]);
    if ww>smax then smax:=ww;
  end;
  smax:=sqrt(smax);
end;

//Read Areas Coordinates from *.res
procedure areaload;
var ms1: TResourcestream;
begin
   ms1 := TResourceStream.Create(hinstance,'e'+inttostr(nr),'RT_RCDATA');
    try
      ms1.readbuffer(fppy,ms1.size);
      punktzahl:=(ms1.size-2) div 2;
  finally
    ms1.Free;
  end;
  flaechenfeld:=@fppy;
end;

</br>

OpenGL:

The OpenGL specification describes an abstract application programming interface (API) for drawing 2D and 3D graphics. It is designed to be implemented mostly or entirely using hardware acceleration such as a GPU, although it is possible for the API to be implemented entirely in software running on a CPU.

Render to Bitmap Frames:

In typical uncompressed Bitmaps, image Pixels are generally stored with a variable number of bits per pixel which identify its color (the color depth). Pixels of 8 bits and fewer can represent either grayscale or indexed color. An alpha channel (for transparency) may be stored in a separate bitmap, where it is similar to a grayscale bitmap, or in a fourth channel that, for example, converts 24-bit images to 32 bits per pixel.

Code Example:

pascal
procedure TForm1.Button1Click(Sender: TObject);
var
  Bitmap: TBitmap;
  DC: HDC;
  FileName: string;
begin
  // Render Bitmap Picture Image
  Bitmap := TBitmap.Create;
  try
    Assert(HandleAllocated);
    DC := GetWindowDC(Handle);
    Win32Check(DC <> 0);

    if RadioButton4.Checked = true then Bitmap.PixelFormat := pf4bit;
    if RadioButton5.Checked = true then Bitmap.PixelFormat := pf8bit;
    if RadioButton6.Checked = true then Bitmap.PixelFormat := pf24bit;
    if RadioButton7.Checked = true then Bitmap.PixelFormat := pf32bit;

    if CheckBox2.Checked = true then begin
      Bitmap.SetSize(Width-ListBox1.Width, Height-280);
      Win32Check(BitBlt(Bitmap.Canvas.Handle, 0, 0,
                Width-ListBox1.Width, Height-280,
                DC, 50, 50, SRCCOPY));
    end;

    if CheckBox2.Checked =false then begin
      Bitmap.SetSize(Width-100, Height-280);
      Win32Check(BitBlt(Bitmap.Canvas.Handle, 0, 0,
                Width-100, Height-280,
                DC, 50, 50, SRCCOPY));
    end;

    FileName := '.' + GraphicExtension(TBitmap);
    if SaveDialog1.Execute then Bitmap.SaveToFile(SaveDialog1.FileName + FileName);
  finally
    ReleaseDC(Handle, DC);
    Bitmap.Free;
  end;
end;

</br>

Classification:

  • Number of sides Polygons are primarily classified by the number of sides.
  • Convexity and intersection Polygons may be characterized by their convexity or type of non-convexity:
  • Convex: any line drawn through the polygon (and not tangent to an edge or corner) meets its boundary exactly twice. As a consequence, all its interior angles are less than 180°. Equivalently, any line segment with endpoints on the boundary passes through only interior points between its endpoints. This condition is true for polygons in any geometry, not just Euclidean.
  • Non-convex: a line may be found which meets its boundary more than twice. Equivalently, there exists a line segment between two boundary points that passes outside the polygon.
  • Simple: the boundary of the polygon does not cross itself. All convex polygons are simple.
  • Concave: Non-convex and simple. There is at least one interior angle greater than 180°.
  • Star-shaped: the whole interior is visible from at least one point, without crossing any edge. The polygon must be simple, and may be convex or concave. All convex polygons are star-shaped.
  • Self-intersecting: the boundary of the polygon crosses itself. The term complex is sometimes used in contrast to simple, but this usage risks confusion with the idea of a * complex polygon as one which exists in the complex Hilbert plane consisting of two complex dimensions.
  • Star polygon: a polygon which self-intersects in a regular way. A polygon cannot be both a star and star-shaped.

</br>

</br>

Equality and symmetry:

The property of regularity may be defined in other ways: a polygon is regular if and only if it is both isogonal and isotoxal, or equivalently it is both cyclic and equilateral. A non-convex regular polygon is called a regular star polygon.

</br>

Polyhedra Calculator:

In geometry, a polyhedron (pl.: polyhedra or polyhedrons; from Greek πολύ (poly-) 'many' and ἕδρον (-hedron) 'base, seat') is a three-dimensional figure with flat polygonal faces, straight edges and sharp corners or vertices. The term "polyhedron" may refer either to a solid figure or to its boundary surface. The terms solid polyhedron and polyhedral surface are commonly used to distinguish the two concepts. Also, the term polyhedron is often used to refer implicitly to the whole structure formed by a solid polyhedron, its polyhedral surface, its faces, its edges, and its vertices.

</br>

</br>

There are many definitions of polyhedra, not all of which are equivalent. Under any definition, polyhedra are typically understood to generalize two-dimensional polygons and to be the three-dimensional specialization of polytopes (a more general concept in any number of dimensions). Polyhedra have several general characteristics that include the number of faces, topological classification by Euler characteristic, duality, vertex figures, surface area, volume, interior lines, Dehn invariant, and symmetry. A symmetry of a polyhedron means that the polyhedron's appearance is unchanged by the transformation such as rotating and reflecting.

Wiki : https://en.wikipedia.org/wiki/Polyhedron

</br>

Kaleidocycle :

A kaleidocycle or flextangle is a flexible polyhedron connecting six tetrahedra (or disphenoids) on opposite edges into a cycle. If the faces of the disphenoids are equilateral triangles, it can be constructed from a stretched triangular tiling net with four triangles in one direction and an even number in the other direction.

</br>

</br>

The kaleidocycle has degenerate pairs of coinciding edges in transition, which function as hinges. The kaleidocycle has an additional property that it can be continuously twisted around a ring axis, showing 4 sets of 6 triangular faces.

Kaleidocycles can be constructed from a single piece of paper (with dimensions lx21) without tearing or using adhesive.[citation needed] Because of this and their continuous twisting property, they are often given as examples of simple origami toys. The kaleidocycle is sometimes called a flexahedron in analogy to the planar flexagon, which has similar symmetry under flexing transformations.

</br>

</br>

Wiki : https://en.wikipedia.org/wiki/Kaleidocycle

Polyhedron :

In geometry, a polyhedron (pl.: polyhedra or polyhedrons; from Greek πολύ (poly-) 'many' and ἕδρον (-hedron) 'base, seat') is a three-dimensional figure with flat polygonal faces, straight edges and sharp corners or vertices. The term "polyhedron" may refer either to a solid figure or to its boundary surface. The terms solid polyhedron and polyhedral surface are commonly used to distinguish the two concepts. Also, the term polyhedron is often used to refer implicitly to the whole structure formed by a solid polyhedron, its polyhedral surface, its faces, its edges, and its vertices.

</br>

</br>

There are many definitions of polyhedra, not all of which are equivalent. Under any definition, polyhedra are typically understood to generalize two-dimensional polygons and to be the three-dimensional specialization of polytopes (a more general concept in any number of dimensions). Polyhedra have several general characteristics that include the number of faces, topological classification by Euler characteristic, duality, vertex figures, surface area, volume, interior lines, Dehn invariant, and symmetry. A symmetry of a polyhedron means that the polyhedron's appearance is unchanged by a transformation, such as rotating and reflecting.

</br>

</br>

Convex polyhedra are a well-defined class of polyhedra with several equivalent standard definitions. Every convex polyhedron is the convex hull of its vertices, and the convex hull of a finite set of points is a polyhedron. Many common families of convex polyhedra, with cubes and pyramids are familiar examples of such.

Wiki : https://en.wikipedia.org/wiki/Polyhedron