JPH11110569A - Inner point discriminating method for graphic - Google Patents

Inner point discriminating method for graphic

Info

Publication number
JPH11110569A
JPH11110569A JP9281137A JP28113797A JPH11110569A JP H11110569 A JPH11110569 A JP H11110569A JP 9281137 A JP9281137 A JP 9281137A JP 28113797 A JP28113797 A JP 28113797A JP H11110569 A JPH11110569 A JP H11110569A
Authority
JP
Japan
Prior art keywords
point
polygon
convex polygon
plane
vertices
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP9281137A
Other languages
Japanese (ja)
Inventor
Akira Asai
朗 浅井
Shigeki Matsutani
茂樹 松谷
Tomoyuki Noda
智之 野田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Canon Inc
Original Assignee
Canon Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Canon Inc filed Critical Canon Inc
Priority to JP9281137A priority Critical patent/JPH11110569A/en
Publication of JPH11110569A publication Critical patent/JPH11110569A/en
Pending legal-status Critical Current

Links

Landscapes

  • Image Analysis (AREA)

Abstract

PROBLEM TO BE SOLVED: To discriminate the inner point of a graphic in a short time by checking whether or not all the outer products of two vectors whose terminating point is successive two points of the sequenced vertexes of a projected polygon and starting point is the point P are the same sign and discriminating whether or not the point P is present inside the projected polygon when the polygon is the projected polygon. SOLUTION: Whether or not all the outer products of the two vectors corresponding to two sides holding the polygon formed by the set of the directed vertexes on a plane and the sequenced vertexes of the polygon to the point P on the plane there between are of the same sign is checked, and whether or not the polygon is the projected polygon is discriminated. Then, when it is the projected polygon occording to the discrimination, whether or not all the outer products of the two vectors whose terminating point is successive two points of the sequenced vertexes of the projected polygon and starting point is a point P on the plane are of the same sign is checked, and whether or not the point P on the plane is present inside the projected polygon is discriminated. Thus, calculation force required for discriminating the inner point of the graphic is reduced and the inner point of the graphics is discriminated in a short time.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、計算機を使用した
数値シミュレーションやグラフィック描画装置等に利用
される図形の内点判定方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a method for determining an inner point of a graphic used in a numerical simulation using a computer, a graphic drawing device, or the like.

【0002】[0002]

【従来の技術】平面上に与えられた点が同一平面上の閉
曲線の内に存在するか否かという問題は、数学的興味か
ら古くから研究されてきた。現在では基本群と呼ばれる
トポロジーの言葉で最も厳密かつ抽象的に表現する事が
可能であるが、留数の定理に関連する解析的な問題でも
ある。
BACKGROUND OF THE INVENTION The problem of whether a given point on a plane lies within a closed curve on the same plane has long been studied due to mathematical interest. At present, it is possible to express it most strictly and abstractly in terms of topology called the fundamental group, but it is also an analytical problem related to the residue theorem.

【0003】与えられた平面に自然な複素座標を導入す
る事によって平面を複素平面とみなし、与えられた閉曲
線をΓとし、与えられた点をz0 とすると、関数f
(z)=1/(z−z0)として、次の一周積分
When a plane is regarded as a complex plane by introducing natural complex coordinates into a given plane, a given closed curve is represented by Γ, and a given point is represented by z0, a function f
(Z) = 1 / (z−z0), and the following one-round integration

【0004】[0004]

【数1】 を計算する事によって、与えられた点が該閉曲線の内点
か否かを判定できる。つまり、留数の定理によると、こ
の積分の値が零であれば、z0は曲線の外に存在し、零
でなければ、即ち±2πiであれば、点は閉曲線内の点
である事が判明する。
(Equation 1) By calculating, it can be determined whether or not the given point is the inner point of the closed curve. In other words, according to the residue theorem, if the value of this integral is zero, z0 is outside the curve, and if it is not zero, that is, if ± 2πi, the point is a point in the closed curve. Prove.

【0005】デュドネ編「数学史1700−1900
I」(岩波書店1985年発行)によると、留数の定理
を発見したのはコーシーのようである。1826年のS
urun nouveaugenre de calc
ul analogue au calcul inf
initesmalという題の論文(Exercice
s de mathematiques)において、特
異点の周りの無限小解析を行う事により、留数の定理を
発見したとある。コーシーはその後、長方形の周りでの
複素函数の積分がその内部の留数の総和である事を計算
し、その後20年に亙り、この間題に深く関わったとあ
る。この留数の計算をもって幾何学と函数論とが結びつ
いたといっても過言ではない。つまり、解析的な関数の
値の和(積分)によって純粋に幾何学的な事実が判明す
るのである。
Dudenet, "History of Mathematics 1700-1900"
According to I "(Iwanami Shoten, 1985), it seems that Cauchy discovered the residue theorem. 1826 S
urun nouveaugenre de calc
ul analoge au calcul inf
A paper entitled "initesmal" (Exercise)
It is said that in s de mathematics, the infinitesimal analysis around the singularity was performed to find the residue theorem. Cauchy later calculated that the integral of the complex function around the rectangle was the sum of the residues inside it, and for the next 20 years he was heavily involved in this subject. It is no exaggeration to say that the calculation of the residue linked geometry with function theory. In other words, a purely geometric fact is revealed by the sum (integration) of the values of the analytical functions.

【0006】実際の計算においては、閉曲線は任意のも
のではなく、区分的に直線で表されたものがより実用的
に重要である。つまり、多角形と点Pが与えられた際に
点Pが多角形の内部にあるか否かの判定をする場合が多
い。
[0006] In actual calculations, the closed curve is not arbitrary, and a piecewise straight line is more practically important. That is, when a polygon and a point P are given, it is often determined whether or not the point P is inside the polygon.

【0007】上述の留数の定理に従った内外判定アルゴ
リズムは、多角形の各辺の点Pからのぞむ角度を計算
し、その角度の総和が±2πであるか否かを調べる必要
がある。しかしながら、角度の計算は超越関数である逆
三角関数を使うため、計算時間を多く必要とするもので
ある。
The inside / outside judgment algorithm according to the above-described residue theorem needs to calculate the angle of each side of the polygon from the point P and check whether or not the sum of the angles is ± 2π. However, since the calculation of the angle uses an inverse trigonometric function, which is a transcendental function, the calculation time is long.

【0008】この点を考慮して、上記留数の定理に沿っ
た内外判定を多くの場合使わずに内外判定を行う方法
(折線からなる図形の内外判定方法)が提案されてい
る。
In consideration of this point, there has been proposed a method of performing inside / outside determination without using the inside / outside determination according to the above-mentioned residue theorem in many cases (inside / outside determination method for a figure composed of a broken line).

【0009】この従来技術は、上述の留数の定理を利用
したものとxy一座標の特徴を利用した外接する長方形
での内外判定を組み合わせたものであり、計算時間を多
く必要な留数の定理を利用した内外判定の問題点を避け
るために、図6に示すような流れ図に従ったアルゴリズ
ムが提供されている。
This prior art is a combination of the above-described residue theorem and the inside / outside judgment of a circumscribed rectangle using the characteristic of xy coordinates, and requires a long calculation time for the residue. In order to avoid the problem of the inside / outside judgment using the theorem, an algorithm according to a flowchart as shown in FIG. 6 is provided.

【0010】図7(a)に示すように多角形Aと点Pが
与えられた時、多角形Aを内包する長方形を多角形Aの
座標のx軸、y軸の最大値及び最小値を利用し、図7
(b)に示すように形成する。
As shown in FIG. 7A, when a polygon A and a point P are given, a rectangle containing the polygon A is defined by the maximum value and the minimum value of the x-axis and the y-axis of the coordinate of the polygon A. Use, Figure 7
It is formed as shown in FIG.

【0011】図6のフローチャートにおいては、まず始
めに図形の埋め込まれたxy座標のx,y軸のそれぞれ
の最大値、最小値によって形成される長方形Dに関し
て、予めに大小判定による内外判定を行い(ステップS
101)、その後、該長方形Dの内であるとした場合は
(ステップS102)、長方形D内の点に対する多角形
の内外判定を行う事となっている(ステップS103〜
S106)。
In the flowchart of FIG. 6, first, an inside / outside judgment is made by a size judgment in advance for a rectangle D formed by the maximum value and the minimum value of the x and y axes of the xy coordinates in which the figure is embedded. (Step S
101) Thereafter, when it is determined that the object is within the rectangle D (step S102), the inside and outside of the polygon are determined with respect to the points in the rectangle D (steps S103 to S103).
S106).

【0012】このような与えられた点が図形の内点か否
かを判定する必要性は計算機の性能の発達とともに近
年、非常に増加していると考えられる。近年のグラフィ
ック描画装置あるいはそれに関する基本的な問題におい
ては、マウス等で指示した点が、与えられた図形の内点
か否かという判定を必要とする。また、モンテカルロ法
等の数値計算においては、多数の点が一つの多角形の内
点か否かを判断する事が求められる。
It is considered that the necessity of determining whether or not such a given point is an inner point of a figure has increased significantly in recent years with the development of computer performance. In a recent graphic drawing apparatus or a basic problem related thereto, it is necessary to determine whether or not a point designated by a mouse or the like is an inner point of a given figure. In numerical calculations such as the Monte Carlo method, it is required to determine whether or not many points are inside points of one polygon.

【0013】本発明の想定する内外判定を行う状況は、
例えば、多角形は初期状態に固定され、その後に千個程
度以上の点がランダムに与えられた際の各点が該多角形
の内点か否かを判定する事である。従って、初期情報と
して多角形に対して補助的な情報を付加しても、全点に
対する内外判定の全判定計算時間を比較して十分小さな
ものとなる場合である。
The situation in which the inside / outside judgment assumed in the present invention is made is
For example, a polygon is fixed in an initial state, and thereafter, when about 1000 or more points are randomly given, it is determined whether or not each point is an inner point of the polygon. Therefore, even when supplementary information is added to the polygon as the initial information, the total determination calculation time for inside / outside determination for all points is sufficiently small.

【0014】更に、上記従来技術においては、一般の多
角形に対する内点判定は計算時間を非常に必要とするた
め、多角形を埋め込んだ長方形に対する予備的内点判定
を行った後に、もしも、目的とする点が長方形外に存在
した場合は、該点が該多角形の外部に存在していると判
定し、また逆に長方形の内部に存在した場合は、計算時
間の掛かる該多角形と点に対する内外判定を行ってい
た。
Furthermore, in the above prior art, since the interior point determination for a general polygon requires a great deal of calculation time, after performing a preliminary interior point determination for a rectangle in which a polygon is embedded, if the preliminary If the point exists outside the rectangle, it is determined that the point exists outside the polygon. Conversely, if the point exists inside the rectangle, the polygon and the point, which take a long time to calculate, Was judged inside and outside.

【0015】[0015]

【発明が解決しようとする課題】しかしながら、上記従
来技術では、次のような問題点があった。
However, the above-mentioned prior art has the following problems.

【0016】図8に示したような多角形A’がxy軸に
対して斜めの方向に延びている場合、対応するx軸、y
軸の最大値及び最小値から形成される長方形D’は、広
い面積を持つ。そのため、図6のフローチャートに沿っ
た予備的な内点判定を行う長方形の面積が本来求めたい
多角形の面積に比較して非常に大きくなり、ランダムな
点分布を考えた場合、予備的内点判定が十分機能してい
ない事となる。
When a polygon A 'as shown in FIG. 8 extends in a direction oblique to the xy axis, the corresponding x axis, y
The rectangle D 'formed from the maximum and minimum values of the axis has a large area. Therefore, the area of a rectangle for performing preliminary interior point determination according to the flowchart of FIG. 6 is very large compared to the area of a polygon originally desired, and when considering a random point distribution, the preliminary interior point The judgment is not functioning enough.

【0017】つまり、予備的な内点判定を行っても、次
の詳細な内点判定の計算を行う必要が非常に多くの場合
に生じ、高速化が行えない。
That is, even if the preliminary interior point determination is performed, it is necessary in many cases to calculate the following detailed interior point determination, and the speed cannot be increased.

【0018】本発明は上記従来の問題点に鑑み、短時間
で図形の内点判定を行うことができる図形の内点判定方
法を提供することを目的とする。
The present invention has been made in view of the above-described conventional problems, and has as its object to provide a method for determining an inner point of a figure, which can determine an inner point of the figure in a short time.

【0019】[0019]

【課題を解決するための手段】上記目的を達成するため
に、第1の発明は、平面上の向き付けられた頂点の集合
によって形成された多角形と、平面上の点Pとに対し
て、前記多角形の順序付けられた頂点を挟む2辺に対応
する2つのベクトルの外積が全て同符号であるか否かを
調べて、前記多角形が凸多角形であるか否かを判定し、
凸多角形である場合には、該凸多角形の順序付けられた
頂点の連続する2点を終点とし前記点Pを始点とする2
つのベクトルの外積が全て同符号であるか否かを調べ
て、該点Pが凸多角形の内部に存在するか否かを判定す
るようにしたものである。
In order to achieve the above object, a first aspect of the present invention relates to a polygon formed by a set of oriented vertices on a plane and a point P on a plane. Checking whether or not the outer products of the two vectors corresponding to the two sides sandwiching the ordered vertices of the polygon are all the same sign, and determining whether the polygon is a convex polygon,
In the case of a convex polygon, two consecutive points of ordered vertices of the convex polygon are set as end points and the point P is set as a start point.
It is determined whether or not the outer products of two vectors have the same sign to determine whether or not the point P exists inside the convex polygon.

【0020】第2の発明では、上記第1の発明におい
て、前記多角形が凸多角形であるか否かの判定で、凸多
角形でないと判定された場合には、該凸多角形の順序付
けられた頂点の連続する2点を終点とし前記点Pを始点
とする2つのべクトルのなす角の総和を調べて、該点P
が凸多角形の内部に存在するか否かを判定するようにし
たものである。
According to a second aspect of the present invention, in the first aspect, if it is determined that the polygon is not a convex polygon, it is determined that the polygon is not a convex polygon. The sum of the angles formed by the two vectors starting from the point P as the end point and the point P as the starting point is checked, and the point P
Is determined whether or not exists inside the convex polygon.

【0021】第3の発明では、平面上の向き付けられた
頂点の集合によって形成された凸多角形と、平面上の点
Pとに対して、前記凸多角形の順序付けられた頂点の連
続する2点を終点とし前記点Pを始点とする2つのベク
トルの外積が全て同符号であるか否かを調べて、前記点
Pが凸多角形の内部に存在するか否かを判定するように
したものである。
In the third aspect of the present invention, with respect to a convex polygon formed by a set of oriented vertices on a plane and a point P on the plane, a sequence of the ordered vertices of the convex polygon is continuous. By examining whether or not the outer products of two vectors having two points as end points and the point P as a starting point have the same sign, it is determined whether or not the point P exists inside the convex polygon. It was done.

【0022】第4の発明では、平面上の3角形DEF
と、平面上の点Pとに対して、ベクトルの外積PD×P
E、PE×PF、PF×PDが全て同符号であるか否か
を調べて、前記点Pが3角形ABCの内部に存在するか
否かを判定するようにしたものである。
In the fourth invention, a triangular DEF on a plane
And a point P on the plane, a vector cross product PD × P
It is determined whether or not the point P exists inside the triangle ABC by checking whether E, PE × PF, PF × PD all have the same sign.

【0023】第5の発明では、平面上の向き付けられた
頂点の集合によって形成された多角形と、平面上の点P
とに対して、前記多角形の順序付けられた頂点を挟む2
辺に対応する2つのベクトルの外積が全て同符号である
か否かを調べて、前記多角形が凸多角形であるか否かを
判定する第1の判定手段と、前記第1の判定手段で凸多
角形であると判定された場合には、該凸多角形の順序付
けられた頂点の連続する2点を終点とし前記点Pを始点
とする2つのベクトルの外積が全て同符号であるか否か
を調べて、該点Pが凸多角形の内部に存在するか否かを
判定する第2の判定手段とを有するプログラムを記憶し
たものである。
In the fifth invention, a polygon formed by a set of oriented vertices on a plane and a point P on the plane
With respect to 2 that sandwich the ordered vertices of the polygon
First determining means for determining whether or not the outer products of the two vectors corresponding to the sides have the same sign and determining whether or not the polygon is a convex polygon; and the first determining means When it is determined that the convex polygon is a convex polygon, whether the outer products of the two vectors starting from the continuous point of the ordered vertices of the convex polygon and the starting point of the point P are all the same sign A program for determining whether or not the point P exists inside the convex polygon by checking whether the point P exists inside the convex polygon.

【0024】第6の発明では、上記第5の発明におい
て、前記第1の判定手段の判定で、凸多角形でないと判
定された場合には、該凸多角形の順序付けられた頂点の
連続する2点を終点とし前記点Pを始点とする2つのべ
クトルのなす角の総和を調べて、該点Pが凸多角形の内
部に存在するか否かを判定する第3の判定手段を有する
プログラムを記憶したものである。
In a sixth aspect based on the fifth aspect, if the first determining means determines that the convex polygon is not a convex polygon, the sequence of the ordered vertices of the convex polygon is continuous. A third determining unit that determines whether or not the point P exists inside the convex polygon by examining the sum of angles formed by two vectors having the two points as end points and the point P as a starting point; It is a program that stores a program.

【0025】第7の発明では、平面上の向き付けられた
頂点の集合によって形成された凸多角形と、平面上の点
Pとに対して、前記凸多角形の順序付けられた頂点の連
続する2点を終点とし前記点Pを始点とする2つのベク
トルの外積が全て同符号であるか否かを調べて、前記点
Pが凸多角形の内部に存在するか否かを判定する手段を
有するプログラムを記憶したものである。
According to the seventh aspect, the ordered vertices of the convex polygon are continuous with respect to a convex polygon formed by a set of oriented vertices on the plane and a point P on the plane. A means for checking whether or not the outer products of two vectors starting from the two points and having the point P as the starting point have the same sign to determine whether or not the point P exists inside the convex polygon. Is stored.

【0026】第8の発明では、平面上の3角形DEF
と、平面上の点Pとに対して、ベクトルの外積PD×P
E、PE×PF、PF×PDが全て同符号であるか否か
を調べて、前記点Pが3角形ABCの内部に存在するか
否かを判定する手段を有するプログラムを記憶したもの
である。
In the eighth invention, a triangular DEF on a plane
And a point P on the plane, a vector cross product PD × P
A program having means for checking whether E, PE × PF, and PF × PD all have the same sign to determine whether or not the point P exists inside the triangle ABC is stored. .

【0027】[0027]

【発明の実施の形態】以下、図面を参照して本発明の実
施の形態を説明する。
Embodiments of the present invention will be described below with reference to the drawings.

【0028】[第1実施形態]初めに、第1実施形態の
概要を説明する。
[First Embodiment] First, the outline of the first embodiment will be described.

【0029】想定している多角形が向きづけられた凸多
角形である場合は、一般の場合より少ない計算量で内点
判定を行うことができる。すなわち、与えられた点Pと
該凸多角形の連続する各辺の終点とで作る外積を計算
し、これらが全て同符号であれば、点Pは凸多角形の内
部にあると判定することができ、異符号のものがあれ
ば、点Pは凸多角形の外部にあると判定することができ
る。
When the assumed polygon is an oriented convex polygon, the interior point can be determined with a smaller amount of calculation than in a general case. That is, the cross product formed by the given point P and the end point of each continuous side of the convex polygon is calculated, and if all these have the same sign, it is determined that the point P is inside the convex polygon. If there is a different sign, it can be determined that the point P is outside the convex polygon.

【0030】また、想定している多角形が凸多角形であ
るであるかどうかは、各頂点を挟む2辺に対応するべク
トルの外積を計算し、これらが全て同符号であれば凸多
角形、異符号のものがあれば非凸多角形であると判定す
ることができる。
To determine whether or not the assumed polygon is a convex polygon, the outer product of vectors corresponding to two sides sandwiching each vertex is calculated. If there is a square or a different sign, it can be determined to be a non-convex polygon.

【0031】これらの判定に必要な外積の計算は、簡単
な加減除の計算であり、逆三角関数などの超越関数の計
算を必要としない。
The calculation of the cross product required for these determinations is a simple addition / subtraction calculation, and does not require calculation of a transcendental function such as an inverse trigonometric function.

【0032】そこで、本実施形態では、次のような内点
判定方法を行う。
Therefore, in the present embodiment, the following interior point determination method is performed.

【0033】まず、平面上の向き付けられた頂点の集合
によって形成された多角形と、平面上の点Pに対して該
多角形の順序付けられた頂点とを挟む2辺に対応する2
つのべクトルの外積が全て同符号であるかどうかを調べ
る。これにより、該多角形が凸多角形であるかどうかを
判定する。
First, a polygon formed by a set of oriented vertices on a plane and a point P on the plane corresponding to two sides sandwiching the ordered vertices of the polygon with respect to a point P
Checks whether the outer products of two vectors have the same sign. Thereby, it is determined whether or not the polygon is a convex polygon.

【0034】(a)凸多角形である場合には、該凸多角
形の順序付けられた頂点の連続する2点を終点とし該点
Pを始点とする2つのべクトルの外積が全て同符号であ
るかどうかを調べることにより、該点Pが凸多角形の内
部に存在するか否かを判定する。
(A) In the case of a convex polygon, the outer product of two vectors starting from the continuous point of the ordered vertices of the convex polygon and ending with the point P has the same sign. By checking whether or not there is, it is determined whether or not the point P exists inside the convex polygon.

【0035】(b)凸多角形でない場合には、該多角形
の順序付けられた頂点の連続する2点を終点とし該点P
を始点とする2つのベクトルの成す角の総和を調べるこ
とにより、該点Pが多角形の内部に存在するか否かを判
定する。
(B) If the polygon is not a convex polygon, two consecutive points of the ordered vertices of the polygon are defined as the end point and the point P
By examining the sum of the angles formed by the two vectors starting from, it is determined whether or not the point P exists inside the polygon.

【0036】以下、図1〜図4を用いて具体的に説明す
る。
Hereinafter, a specific description will be given with reference to FIGS.

【0037】図1は、本発明の第1実施形態に係る図形
の内点判定方法を示すフローチャートである。図2は図
1中のアルゴリズム甲を示すフローチャート、及び図3
は図1中のアルゴリズム乙を示すフローチャートであ
る。また、図4は、第1実施形態で使用した多角形Aを
示す図である。
FIG. 1 is a flow chart showing a method for determining an inner point of a graphic according to the first embodiment of the present invention. FIG. 2 is a flowchart showing the algorithm A in FIG. 1, and FIG.
3 is a flowchart showing Algorithm B in FIG. FIG. 4 is a diagram showing the polygon A used in the first embodiment.

【0038】図4に示すように、ある平面C内に向き付
けられた多角形Aが存在しているとする。向き付けられ
たとは、多角形Aを構成する辺に対して、一方向の矢印
が自然に定義できるという事である。当然であるが、こ
の矢印の方向には2つの自由度、即ち右回りと左回りの
自由度が存在している。向きを付けるという事は、この
2つの自由度に対してその一つを選ぶという事と等し
い。
As shown in FIG. 4, it is assumed that a polygon A oriented in a certain plane C exists. To be oriented means that a one-way arrow can be naturally defined with respect to a side constituting the polygon A. Naturally, there are two degrees of freedom in the direction of the arrow, that is, clockwise and counterclockwise. Orienting is equivalent to choosing one of these two degrees of freedom.

【0039】このように与えられた向きに対して、多角
形のある頂点から出発して一周する事で、多角形の頂点
の点列が図4に示すように形成される。その点列を(X
j,Yj)(j=0,…,N)とする。但し、(X0,
Y0)=(XN,YN)この時、更に図4に示すように同
一平面C上に別の点P(X,Y)が存在しているとす
る。本発明の課題は、この点Pが多角形Aの内に存在し
ているか否かを判定する事にある。
By starting from a certain vertex of the polygon and making a round in the direction given in this way, a point sequence of the vertices of the polygon is formed as shown in FIG. The sequence of points is (X
j, Yj) (j = 0,..., N). However, (X0,
Y0) = (XN, YN) At this time, it is assumed that another point P (X, Y) exists on the same plane C as shown in FIG. An object of the present invention is to determine whether or not this point P exists within a polygon A.

【0040】そこで、まずは、従来の技術で述べた留数
の定理に従った(多くの計算時間を必要とする)内点判
定アルゴリズム乙について説明を行う。
First, a description will be given of an interior point determination algorithm B according to the residue theorem described in the prior art (which requires a lot of calculation time).

【0041】次の量を定義する。The following quantities are defined:

【0042】 Si=(Xi−X)(Yi+1−Y)−(Yi−Y)(Xi+1−X) Ci=(Xi−X)(Xi+1−X)+(Yi−Y)(Yi+1−Y) φi=atan2(Si,Ci) 但し、i=0,…,N-1であり、atan2は、FOR
TRAN言語やC言語で利用可能な逆正接関数を表すも
のとする。すなわち、θ=atan2(Y,X)は、
Si = (Xi−X) (Yi + 1−Y) − (Yi−Y) (Xi + 1−X) Ci = (Xi−X) (Xi + 1−X) + (Yi−Y) (Yi + 1−Y) φi = atan2 (Si, Ci) where i = 0,..., N−1 and atan2 is FOR
It represents an arctangent function available in the TRAN language or the C language. That is, θ = atan2 (Y, X) is

【0043】[0043]

【数2】 の関係を満たす。Si=Ci=0の場合は、Pが多角形
の頂点に一致する場合なので、内点ではないと判定でき
る。
(Equation 2) Satisfy the relationship. If Si = Ci = 0, it means that P coincides with the vertex of the polygon, so it can be determined that it is not an interior point.

【0044】このようにして、Thus,

【0045】[0045]

【数3】 は、点Pが多角形Aの内部に存在すれば、±2πとな
り、外点の場合は零となる。このアルゴリズムの事をこ
こではアルゴリズム乙と呼ぶ(図3のステップS11〜
ステップS20)。このアルゴリズム乙と同様なアルゴ
リズムは、例えば、前述した従来技術において述べられ
ている。
(Equation 3) Is ± 2π if the point P is inside the polygon A, and is zero if it is an outside point. This algorithm is referred to herein as algorithm B (steps S11 to S11 in FIG. 3).
Step S20). An algorithm similar to the algorithm B is described, for example, in the above-described prior art.

【0046】しかしながら、この計算はatan2とぃ
ぅ超越関数を使うため、計算に時間がかかる。そこで、
次の事実を考える。
However, since this calculation uses atan2 and the ぃ ぅ transcendental function, the calculation takes time. Therefore,
Consider the following facts.

【0047】与えられた多角形が凸多角形である特殊な
場合を考察する。凸多角形とはその内角のすべてが、π
以下の多角形の事である。この場合、点Pと凸多角形の
各辺の終点とを結ぶべクトルの外積Siはもし内点であ
ればすべて同符号となり、外点であれば符号の異なるも
のを含む事となる。
Consider the special case where a given polygon is a convex polygon. A convex polygon has all its interior angles π
It is the following polygon. In this case, the outer product Si of the vector connecting the point P and the end point of each side of the convex polygon has the same sign if it is an inner point, and includes a different sign if it is an outer point.

【0048】従って、凸多角形の場合は次のような計算
を行えば内点判定を行う事が可能である。まず、多角形
の頂点を適当に選ぶ。選ばれた頂点から多角形の向きに
沿って、Siの計算を行い、隣のSiとの積を計算す
る。これが正であれば、SiとSi+1とは同符号である
事を意味する。即ち、 Si・Si+1>0 である事を確かめる。もしも、どこかでSi・Si+1が
0または負になる点が存在すれば、与えられた点Pは内
点でない事を意味する。
Therefore, in the case of a convex polygon, the interior point can be determined by performing the following calculation. First, select the vertices of the polygon appropriately. The Si is calculated from the selected vertex along the direction of the polygon, and the product with the next Si is calculated. If this is positive, it means that Si and Si + 1 have the same sign. That is, it is confirmed that Si · Si + 1> 0. If there is a point where Si · Si + 1 becomes 0 or negative, it means that the given point P is not an inner point.

【0049】この事実にたった内点判定アルゴリズムを
アルゴリズム甲と呼ぶ(図2のステップS21〜ステッ
プS28)。この場合、atan2等の超越関数を使用
する事なく、単純な掛け算と引き算のみの計算で内点か
否かを判定できるため、アルゴリズム乙に比較して非常
に高速となる。
The algorithm for determining the interior point that satisfies this fact is called algorithm A (steps S21 to S28 in FIG. 2). In this case, since it is possible to determine whether or not an inner point is obtained by a simple multiplication and subtraction calculation without using a transcendental function such as atan2, the processing speed is much higher than that of Algorithm B.

【0050】想定している多角形が凸多角形であるであ
るかどうかは、各頂点を挟む2辺に対応するべクトルの
外積を計算し、これらが全て同符号であれば、凸多角
形、異符号のものがあれば、非凸多角形であると判定す
ることができる。
To determine whether or not the assumed polygon is a convex polygon, an outer product of vectors corresponding to two sides sandwiching each vertex is calculated, and if all these have the same sign, the convex polygon is determined. If there is a different sign, it can be determined that the object is a non-convex polygon.

【0051】そこで、本実施形態においでは図1に示し
たフローチャート(ステップS21〜ステップS28)
に従った内点判定アルゴリズムを提供する。
Therefore, in the present embodiment, the flowchart shown in FIG. 1 (steps S21 to S28)
Provides an interior point determination algorithm according to

【0052】即ち、まず、図4のような多角形A及び点
Pに対して、これが凸多角形であるかどうかの判定(ス
テップS31〜ステップS37)を行った後、もしも凸
多角形であれば先のアルゴリズム甲を適用する(ステッ
プS38)。もしも非凸多角形であれば、先のアルゴリ
ズム乙を適用することにより(ステップS39)内点判
定を行う。
That is, first, it is determined whether or not the polygon A and the point P as shown in FIG. 4 are convex polygons (steps S31 to S37). If so, the algorithm A is applied (step S38). If it is a non-convex polygon, the interior point is determined by applying the above algorithm B (step S39).

【0053】この方法に従えば、多角形が非凸多角形の
場合には超越関数の計算を必要とするが、凸多角形の場
合には、簡単な加減乗除だけで内点判定を行うことがで
き、多くの場合に対して計算時間の短縮を図ることがで
きる。
According to this method, when the polygon is a non-convex polygon, the calculation of the transcendental function is required. However, when the polygon is a convex polygon, the interior point is determined only by simple addition, subtraction, multiplication and division. And the calculation time can be reduced in many cases.

【0054】[第2実施形態]上記第1実施形態におい
て、与えられた多角形が向き付けられた凸多角形である
ことが、予め分かっている場合には、アルゴリズム甲の
みで内点判定を行うことができる。
[Second Embodiment] In the first embodiment, if it is known in advance that a given polygon is an oriented convex polygon, the interior point is determined only by the algorithm A. It can be carried out.

【0055】すなわち、計算機内のメモリ上のデータと
して形成された平面上の点Pと該メモリ上に配列として
形成された同一平面内の交点のない向き付けられた凸多
角形に対して、与えられた点Pと該凸多角形の連続する
各辺の終点とで作る外積を計算し、これらが全て同符号
であれば、点Pは凸多角形の内部にあると判定すること
ができ、異符号のものがあれば、点Pは凸多角形の外部
にあると判定される。
That is, given a point P on a plane formed as data on a memory in a computer and an oriented convex polygon having no intersection in the same plane formed as an array on the memory. The cross product formed by the obtained point P and the end point of each continuous side of the convex polygon is calculated, and if these are all the same sign, it can be determined that the point P is inside the convex polygon, If there is a different sign, the point P is determined to be outside the convex polygon.

【0056】[第3実施形態]与えられた多角形が3角
形である場合は、頂点をどのような順番に選んでも、得
られる図形は向き付けられた凸多角形となる。従って、
次のような内点判定アルゴリズムを採用することができ
る。
[Third Embodiment] If the given polygon is a triangle, the obtained figure will be an oriented convex polygon regardless of the order in which the vertices are selected. Therefore,
The following interior point determination algorithm can be employed.

【0057】すなわち、本実施形態で使用する多角形
(3角形)を表す図5において、計算機内のメモリ上の
データとして形成された平面上の点Pと該メモリ上に配
列として形成された同一平面内の3角形DEFに対し
て、べクトルの外積PD×PE、PE×PF、PF×P
Dを計算し、これらが全て同符号であれば、点Pは3角
形DEFの内部にあると判定し、異符号のものがあれ
ば、点Pは3角形DEFの外部にあると判定する。
That is, in FIG. 5 showing a polygon (triangle) used in the present embodiment, points P on a plane formed as data on a memory in a computer are identical to points P formed on the memory as an array. For the triangular DEF in the plane, the outer product of the vectors PD × PE, PE × PF, PF × P
D is calculated, and if they are all the same sign, it is determined that the point P is inside the triangle DEF, and if there is a different sign, it is determined that the point P is outside the triangle DEF.

【0058】要するに、平面上の3角形DEFと平面上
の点Pに対して、ベクトルの外積PD×PE、PE×P
F、PF×PDが全て同符号であるかどうかを調べるこ
とにより、該点Pが3角形ABCの内部に存在するか否
かを判定するすることができる。
In short, for the triangle DEF on the plane and the point P on the plane, the outer products PD × PE, PE × P
By checking whether F and PF × PD have the same sign, it can be determined whether or not the point P exists inside the triangle ABC.

【0059】上記図1乃至図3に示すフローチャートに
従ったプログラムを計算機の記憶装置に格納し動作する
ことにより、計算機を利用した様々な応用分野、例えば
数値シミュレーションやグラフィックスの基本ツール群
としてグラフィック描画装置に応用して、上述の図形の
内点判定方法を実現させることが可能となる。そのプロ
グラムは、例えば、計算機に接続された外部記憶装置
(FD、CD−ROM、ROM、磁気テープ等)に記憶
されており、そのプログラムは計算機内の読み取り装置
によって、記憶装置(メモリ)に記憶させてもよい。
By storing a program according to the flowcharts shown in FIGS. 1 to 3 in a storage device of a computer and operating the computer, various programs using the computer, for example, a graphic simulation as a basic tool group for numerical simulation and graphics. By applying the present invention to a drawing apparatus, it is possible to realize the above-described method of determining the inside point of a figure. The program is stored in, for example, an external storage device (FD, CD-ROM, ROM, magnetic tape, etc.) connected to the computer, and the program is stored in a storage device (memory) by a reading device in the computer. May be.

【0060】[0060]

【発明の効果】以上詳述したように、本発明の図形の内
点判定方法によれば、多くの場合に図形の内点判定に要
する計算量が少なくて済むため、従来の方法より短時間
で図形の内点判定を行うことが可能になる。
As described above in detail, according to the method for determining the interior point of a graphic according to the present invention, the amount of calculation required for determining the interior point of a graphic is reduced in many cases. Makes it possible to determine the interior point of the figure.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本発明の第1実施形態に係る図形の内点判定方
法を示すフローチャートである。
FIG. 1 is a flowchart illustrating a method of determining an inner point of a graphic according to a first embodiment of the present invention.

【図2】図1中のアルゴリズム甲を示すフローチャート
である。
FIG. 2 is a flowchart showing an algorithm A in FIG.

【図3】図1中のアルゴリズム乙を示すフローチャート
である。
FIG. 3 is a flowchart showing an algorithm B in FIG. 1;

【図4】第1実施形態で使用した多角形Aを示す図であ
る。
FIG. 4 is a diagram showing a polygon A used in the first embodiment.

【図5】第3実施形態で使用した多角形Aを示す図であ
る。
FIG. 5 is a diagram showing a polygon A used in a third embodiment.

【図6】従来の内点判定アルゴリズムを示すフローチャ
ートである。
FIG. 6 is a flowchart showing a conventional interior point determination algorithm.

【図7】従来の内点判定アルゴリズムを示す説明図であ
る。
FIG. 7 is an explanatory diagram showing a conventional interior point determination algorithm.

【図8】従来の内点判定アルゴリズムを示す説明図であ
る。
FIG. 8 is an explanatory diagram showing a conventional interior point determination algorithm.

【符号の説明】[Explanation of symbols]

A:与えられた多角形 P:与えられた点 Q1〜Q5 多角形の頂点 D,E,F 三角形の頂点 A: Given polygon P: Given point Q1 to Q5 Vertex of polygon D, E, F Vertex of triangle

Claims (8)

【特許請求の範囲】[Claims] 【請求項1】 平面上の向き付けられた頂点の集合によ
って形成された多角形と、平面上の点Pとに対して、前
記多角形の順序付けられた頂点を挟む2辺に対応する2
つのベクトルの外積が全て同符号であるか否かを調べ
て、前記多角形が凸多角形であるか否かを判定し、 凸多角形である場合には、該凸多角形の順序付けられた
頂点の連続する2点を終点とし前記点Pを始点とする2
つのベクトルの外積が全て同符号であるか否かを調べ
て、該点Pが凸多角形の内部に存在するか否かを判定す
ることを特徴とする図形の内点判定方法。
1. A polygon formed by a set of oriented vertices on a plane and a point P on a plane correspond to two sides sandwiching the ordered vertices of the polygon.
It is determined whether or not the outer products of the two vectors have the same sign, and it is determined whether or not the polygon is a convex polygon. If the polygon is a convex polygon, the convex polygon is ordered. 2 with two consecutive vertices as end points and the point P as a start point
A method for determining whether or not the point P exists inside a convex polygon by checking whether or not all outer products of two vectors have the same sign.
【請求項2】 前記多角形が凸多角形であるか否かの判
定で、凸多角形でないと判定された場合には、該凸多角
形の順序付けられた頂点の連続する2点を終点とし前記
点Pを始点とする2つのべクトルのなす角の総和を調べ
て、該点Pが凸多角形の内部に存在するか否かを判定す
ることを特徴とする請求項1記載の図形の内点判定方
法。
2. When it is determined that the polygon is not a convex polygon in determining whether or not the polygon is a convex polygon, two consecutive vertices of the ordered vertices of the convex polygon are defined as end points. 2. The graphic according to claim 1, wherein a sum of angles formed by the two vectors starting from the point P is checked to determine whether the point P exists inside the convex polygon. Interior point determination method.
【請求項3】 平面上の向き付けられた頂点の集合によ
って形成された凸多角形と、平面上の点Pとに対して、
前記凸多角形の順序付けられた頂点の連続する2点を終
点とし前記点Pを始点とする2つのベクトルの外積が全
て同符号であるか否かを調べて、前記点Pが凸多角形の
内部に存在するか否かを判定する図形の内点判定方法。
3. For a convex polygon formed by a set of oriented vertices on a plane and a point P on the plane,
It is checked whether or not the outer products of two vectors having the consecutive points of the ordered vertices of the convex polygon as an end point and the point P as a start point are all the same sign, and the point P is a convex polygon. A method for determining the inside point of a figure for determining whether or not it exists inside.
【請求項4】 平面上の3角形DEFと、平面上の点P
とに対して、ベクトルの外積PD×PE、PE×PF、
PF×PDが全て同符号であるか否かを調べて、前記点
Pが3角形ABCの内部に存在するか否かを判定する図
形の内点判定方法。
4. A triangle DEF on a plane and a point P on a plane
And the vector cross product PD × PE, PE × PF,
A method of judging an inside point of a figure, which checks whether or not PF × PD all have the same sign and judges whether or not the point P exists inside the triangle ABC.
【請求項5】 平面上の向き付けられた頂点の集合によ
って形成された多角形と、平面上の点Pとに対して、前
記多角形の順序付けられた頂点を挟む2辺に対応する2
つのベクトルの外積が全て同符号であるか否かを調べ
て、前記多角形が凸多角形であるか否かを判定する第1
の判定手段と、 前記第1の判定手段で凸多角形であると判定された場合
には、該凸多角形の順序付けられた頂点の連続する2点
を終点とし前記点Pを始点とする2つのベクトルの外積
が全て同符号であるか否かを調べて、該点Pが凸多角形
の内部に存在するか否かを判定する第2の判定手段とを
有するプログラムを記憶したことを特徴とする機械読み
出し可能な記憶媒体。
5. A polygon corresponding to a polygon formed by a set of oriented vertices on a plane and a point P on the plane corresponding to two sides sandwiching the ordered vertices of the polygon.
A first check is made to determine whether or not the outer products of the two vectors have the same sign, and to determine whether or not the polygon is a convex polygon.
If the first determining means determines that the convex polygon is a convex polygon, two consecutive points of the ordered vertices of the convex polygon are the end point and the point P is the starting point. A second determining means for determining whether or not the outer products of the two vectors have the same sign, and determining whether or not the point P exists inside the convex polygon. A machine-readable storage medium.
【請求項6】 前記第1の判定手段の判定で、凸多角形
でないと判定された場合には、該凸多角形の順序付けら
れた頂点の連続する2点を終点とし前記点Pを始点とす
る2つのべクトルのなす角の総和を調べて、該点Pが凸
多角形の内部に存在するか否かを判定する第3の判定手
段を有するプログラムを記憶したことを特徴とする請求
項5記載の機械読み出し可能な記憶媒体。
6. If the first determining means determines that the convex polygon is not a convex polygon, two consecutive points of the ordered vertices of the convex polygon are defined as an end point, and the point P is defined as a start point. A program having third determining means for determining whether or not the point P exists inside a convex polygon by examining a sum of angles formed by the two vectors. 6. The storage medium according to claim 5, which is readable by a machine.
【請求項7】 平面上の向き付けられた頂点の集合によ
って形成された凸多角形と、平面上の点Pとに対して、
前記凸多角形の順序付けられた頂点の連続する2点を終
点とし前記点Pを始点とする2つのベクトルの外積が全
て同符号であるか否かを調べて、前記点Pが凸多角形の
内部に存在するか否かを判定する手段を有するプログラ
ムを記憶したことを特徴とする機械読み出し可能な記憶
媒体。
7. For a convex polygon formed by a set of oriented vertices on a plane and a point P on a plane,
It is checked whether or not the outer products of two vectors having the consecutive points of the ordered vertices of the convex polygon as an end point and the point P as a start point are all the same sign, and the point P is a convex polygon. A machine-readable storage medium storing a program having means for determining whether or not it exists inside.
【請求項8】 平面上の3角形DEFと、平面上の点P
とに対して、ベクトルの外積PD×PE、PE×PF、
PF×PDが全て同符号であるか否かを調べて、前記点
Pが3角形ABCの内部に存在するか否かを判定する手
段を有するプログラムを記憶したことを特徴とする機械
読み出し可能な記憶媒体。
8. A triangle DEF on a plane and a point P on a plane
And the vector cross product PD × PE, PE × PF,
A program having means for checking whether or not all of PF × PD have the same sign to determine whether or not the point P exists inside the triangle ABC; Storage medium.
JP9281137A 1997-09-30 1997-09-30 Inner point discriminating method for graphic Pending JPH11110569A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP9281137A JPH11110569A (en) 1997-09-30 1997-09-30 Inner point discriminating method for graphic

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP9281137A JPH11110569A (en) 1997-09-30 1997-09-30 Inner point discriminating method for graphic

Publications (1)

Publication Number Publication Date
JPH11110569A true JPH11110569A (en) 1999-04-23

Family

ID=17634889

Family Applications (1)

Application Number Title Priority Date Filing Date
JP9281137A Pending JPH11110569A (en) 1997-09-30 1997-09-30 Inner point discriminating method for graphic

Country Status (1)

Country Link
JP (1) JPH11110569A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008287337A (en) * 2007-05-15 2008-11-27 Rkc Instrument Inc Method for discriminating interior point of figure
JP2009182637A (en) * 2008-01-30 2009-08-13 Canon Inc Color processor and its method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008287337A (en) * 2007-05-15 2008-11-27 Rkc Instrument Inc Method for discriminating interior point of figure
JP2009182637A (en) * 2008-01-30 2009-08-13 Canon Inc Color processor and its method

Similar Documents

Publication Publication Date Title
US6504541B1 (en) Warping geometric objects
Kallmann Shortest Paths with Arbitrary Clearance from Navigation Meshes.
US20130293554A1 (en) A method for stroking paths
US10984573B2 (en) Collision detection and resolution in virtual environments
CN110598331B (en) Roof modeling method and device
Sheffer Spanning tree seams for reducing parameterization distortion of triangulated surfaces
Veron et al. Shape preserving polyhedral simplification with bounded error
US8654145B2 (en) Binding using rollback
US8289332B2 (en) Apparatus and method for determining intersections
Zhang et al. Adaptive NC path generation from massive point data with bounded error
JPH11110569A (en) Inner point discriminating method for graphic
US20130212537A1 (en) Extracting Feature Information From Mesh
WO2008107859A1 (en) Process for the automatic calculus of the convex or concave hull of an arbitrary set of points
Hou et al. Computing the global visibility map using slice geometry for setup planning
Heo et al. The intersection of two ringed surfaces and some related problems
Ratschek et al. Scci-hybrid methods for 2d curve tracing
Ram et al. The shortest path in a simply-connected domain having a curved boundary
JP2006318336A (en) Figure drawing device
JP2003085569A (en) Inside and outside point discrimination algorithm
Kaye et al. Strategies for evaluating boundary fractal dimensions by computer aided image analysis
JP2000251081A (en) Inner point deciding method, graphic drawing device, and program storage medium
US6957176B2 (en) Reduction processing method and computer readable storage medium having program stored thereon for causing computer to execute the method
KR100395485B1 (en) Sweep-envelope and line-sweep computation method for general sweep boundary
JP2003085577A (en) Inside and outside point discrimination algorithm
Bühler et al. A new intersection algorithm for parametric surfaces based on linear interval estimations