- KVKV-X
2D 2次元座標計算FUN
概略
KEYENCE KV-X・KVシリーズで利用できる2次元座標計算用のファンクションブロック(FB)を紹介します。
距離計算、角度計算、直線の交点計算、座標回転、円の中心座標計算など、
画像処理や位置決め、ロボット制御で利用できる幾何演算を簡単に実装できます。
利用例
- 画像センサで検出した2点間距離の計算
- 2本のエッジ線から交点を求める
- ワーク位置の座標変換
- ロボットハンドの回転補正
- 3点測定による円中心検出
一覧
2点間の距離と角度 (LinearPtoP)

KV-X
- pointA
- 点1 [x,y]
- pointB
- 点2 [x,y]
- distance
- 距離
- angle
- 角度
【例】
pointA = [-6.0, -3.0]
pointB = [5.0, 4.0]
distance = 13.038
angle = 32.471
【 計算式 】
\[ \begin{aligned} distance &= \sqrt{(p2_x-p1_x)^{2}+(p2_y-p1_y)^{2}} \\ angle &= atan2(p2_y-p1_y, p2_x-p1_x) \end{aligned} \] 計算式ではp1[0]を\(p1_x\)、p1[1]を\(p1_y\)と記述しています
2直線の交点と角度 (Intersection)

KV-X
- Line1
- 線1 [x1, y1, x2, y2]
- Line2
- 線2 [x1, y1, x2, y2]
- point
- 交点 [x, y]
- angle
- 角度
【例】
Line1 始点X [0,0] = -10.0
Line1 始点Y [0,1] = -7.0
Line1 終点X [1,0] = 10.0
Line1 終点X [1,1] = 3.0
Line2 始点X [0,0] = -10.0
Line2 始点Y [0,1] = 13.4
Line2 終点X [1,0] = 10.0
Line2 終点X [1,1] = -10.6
point [2, -1]
angle = -76.759
L1,L2から \[ \begin{align} point_x = &\frac{(b2-b1)}{(a1-a2)} \\ point_y = &a1*point_x+b1 \\ angle=&tan^{-1}\left(\frac{a2-a1}{1+a1*a2} \right) \end{align} \]
原点を中心に回転 (PointRotate)

KV-X
- point
- 点 [x,y]
- angle
- 回転角度
- out_point
- 移動後の座標
【例】
point [4, 4]
angle = 90
out_point [-4, 4]
3点を通る円の中心 (GetCenter2D)

KV-X
- pointA
- 点A [x,y]
- pointB
- 点B [x,y]
- pointC
- 点C [x,y]
- point0
- 中心 [x,y]
- radius
- 半径
【例】
pointA [-4, 2]
pointB [3, -1]
pointC [1, 6]
point0 [0.128, 1.965]
radius 4.128




