Previous Page Next Page Contents

plot::Polygon -- graphical primitive for a polygon

Introduction

plot::Polygon(p1, p2...) represents a plot of a polygon build of the points p1, p2, ..., where the points must either be of dimension two or three.

Creating Elements

plot::Polygon(p1, p2... <, option1, option2...>)

Parameters

p1, p2 - plot points, i.e., objects that can be converted into the domain plot::Point; the points must have the same dimension
option1, option2, ... - plot option(s) of the form OptionName = value

Related Domains

DOM_POLYGON, plot::Point, plot::Rectangle2d, plot::Scene, RGB

Related Functions

plot, plot2d, plot3d, plot::copy, plot::line, polygon

Details

Operands

The operands of an object of plot::Polygon are the points p1, p2... (in this order).

Important Operations

Operands of a polygon primitive can be accessed either using the system function op, the index operator [ ], or using the attribute objects described above. For example, if polygon is such an object, then the calls op(polygon,1), polygon[1] and polygon::objects[1] return the first point of polygon.

Via polygon[1] := new_point or polygon::objects[1] := new_point, the first point of polygon is replaced by new_point.

See the methods "op", "_index", "set_index" and "slot" below.

Use the slot operator :: to get or set plot options of such objects afterwards, i.e., when they have been created. For example, if polygon is such an object, then polygon::Color := RGB::Red changes the color of each point of polygon to red.

Result of Evaluation

Evaluating an object of type plot::Polygon returns itself.

Function Call

Calling an object of plot::Polygon as a function yields the object itself, regardless of the arguments. The arguments are not evaluated.

Entries

defaultOptions

is a table of plot options for polygon primitives and their default values. Each entry has the form OptionName = default_value.

When an object of the domain plot::Polygon is created, then a copy of this table is stored under the attribute options (see the table of attributes above), where those options are added and replaced, respectively, which are given by the (optional) parameters option1, option2... of the creating call (see ``Creating Elements'' above).

Plot options, which are not contained in the table stored under the attribute options will not be included in the plot data of the object created by the method "getPlotdata" (see below).

For those options, the corresponding default value either is set by a graphical scene, if the option also exists as a scene option (such as the option PointWidth), or it is internally set by the function plot2d and plot3d, respectively, which are used to plot the object. See the table of plot options above, which gives a summary of the available plot options for polygon primitives and their default values.

To change the default value of some plot options, the option name and its default value may be added to the table "defaultOptions", or replaced by a new value, respectively.

optionNames

is a set of the available option names for plots of polygons.

Method _index: indexed access to the operands of a polygon primitive

Method dimension: dimension of a polygon primitive

Method getPlotdata: create the plot data of a polygon primitive

Method nops: number of operands of a polygon primitive

Method op: extract operands of a polygon primitive

Method set_index: set operands of a polygon primitive

Method slot: read and write attributes and plot options

Method convert: conversion of objects into a polygon primitive

Method convert_to: conversion of a polygon primitive

Method expr: conversion into a system polygon primitive

Method checkOption: check a plot option

Method copy: create a copy of a polygon primitive

Method expose: expose the definition of a polygon

Method modify: modify a copy of a polygon primitive

Method print: print a polygon primitive

Example 1

We create a polygon build of the points (1;2), (10;2) and (10;10):

>> p := plot::Polygon( 
     plot::Point(1, 2), plot::Point(10, 2), plot::Point(10, 10) 
   )
                              plot::Polygon()

and plot the polygon in a graphical scene:

>> plot(p)

Plot options may be specified as additional arguments. For example, to close the polygon created above, set the option Closed to the value TRUE:

>> p := plot::Polygon( 
     plot::Point(1, 2), plot::Point(10, 2), plot::Point(10, 10), 
     Closed = TRUE 
   ):
   plot(p)

You can also set plot options of an object of the domain plot::Polygon via the slot operator ::. For example, to change the color of the polygon p into green and increase the width of the lines of the polygon, e.g., to the value 50, we enter:

>> p::Color := RGB::Red: p::LineWidth:= 50:
   plot(p)

Scene options may be given to the call of plot, such as removing axes from the plot:

>> plot(p, Axes = None)

Example 2

Objects of the domain plot::Polygon, and objects of the basic domain DOM_POLYGON are graphical primitives for two- or three dimensional polygons. The main difference between objects of these two domains is, that objects of plot::Polygon can be used together with other graphical primitives of the library plot such as function graphs, surface plots, point-list plots, and more.

To ease the use of such different objects, you can easily convert objects of one domain into the other. For example, an object of the domain plot::Polygon such as:

>> p := plot::Polygon([1, 2], [2, 3], [0, 3], [-1,2])
                              plot::Polygon()

can be converted into the domain DOM_POLYGON as follows:

>> plot::Polygon::convert_to(p, DOM_POLYGON)
      polygon(point(1.0, 2.0), point(2.0, 3.0), point(0.0, 3.0), poi\
      nt(-1.0, 2.0))

Note that because objects of the domain DOM_POLYGON only know the plot options Color, Filled and Closed, any other plot option set for the object p is lost by this conversion.

With the method "convert", objects can be converted into the domain plot::Polygon. For example, we convert the polygon polygon(point(1, 2, 3), point(2, 4, 6)) into an object of the domain plot::Polygon:

>> p := polygon(point(1, 2, 3), point(2, 4, 6)): 
   q := plot::Polygon::convert(p)
                              plot::Polygon()

One may now override default values of some plot options for the object q as follows:

>> q::Color := RGB::Blue: q::LineWidth := 50:
   plot(q, Axes = None)

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000