raycast op• Data kinds: mesh × keypoints → table
• Call: import cadmap; cadmap.cad_pixel_to_surface(mesh, pixels, K=None, R=None, t=None, cull_backfaces=True, image_size=None, strict=False) (or opscadmap.get("cad_pixel_to_surface"))
Pixels (N,2) → `(face_id, barycentric coordinates, 3-D point)` on the CAD surface (closed form).
> The detailed description below is the original text — the summary and the headings are translated.
画素ごとに視線を作り(`camera.py 規約: 中心は整数座標、u` = 列、
`v` = 行)、Möller-Trumbore で全三角形と交差させ、最も手前の当たりを
採る。当たらない画素には `face_id = -1` を返し、**最寄りの面へは絶対に
丸めない**(検査で「欠陥が背景に載っていた」を「面 17 の欠陥」に化けさせない
ため)。`cull_backfaces=True`(既定)では法線がカメラを向いていない面は
当たりにしない。
返りは dict:
• `face_id (N,) int64 — 当たった三角形の行番号。miss は -1`。
• `bary (N,3) — 重心座標 (w0, w1, w2)、F[face_id]` の 3 頂点の
順。`point = w0*V[i0] + w1*V[i1] + w2*V[i2]` が厳密に成り立つ。
miss は `NaN。辺・頂点上では 1 成分が 0(許容 1e-9`)。
• `point (N,3) — 世界座標の交点。miss は NaN`。
• `depth (N,) — カメラ座標の Z(視線距離ではない)。miss は NaN`。
• `normal` (N,3) — 当たった面の単位法線(世界座標、巻き方どおり)。
miss は `NaN(bary/point/depth` と同じ規約)。
• `hit` (N,) bool。
• `camera 実際に使われた K/R/t/width/height`。
既定に落ちた場合もここを見れば分かる。
• `winding_fixed` bool — 内向きに巻かれた閉メッシュを検出して**この
呼び出しの中で巻きを直した**かどうか。常に入る(`False` でも入る)。
`cull_backfaces=True`(既定)で mesh が閉じていて符号つき体積が負なら、
既定では巻きを直して `winding_fixed=True を返す。strict=True` にすると
直さず `ValueError で拒否する。cull_backfaces=False` のときは裏面判定を
しないので巻き方向は結果に効かず、検査もせず `winding_fixed` は常に
`False(normal` は入力の巻きどおりの符号で返る)。詳細は
:func:_orient_for_culling。
`K/R/t` を省くと mesh を画像に収める既定カメラを作る
(`R = I、カメラは重心の -Z 側)。image_size` を省くと**与えた画素の
外接箱**から画像サイズを決める — 既定カメラが画素のある場所を見るように
するためで、`K を明示したときは in_image` 判定にしか効かない。
• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).
• Operator provenance and references — the sources of the research/methods this op family came from.
• The canonical algorithm (author, year) and its uses are named in the family usage guide above.
• defect_to_cad — py -3.11 examples/defect_to_cad.py
table as input)—
raycast)—
*Provenance: cadmap.py — CADMAP operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*
© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.