MustafaMulla29/rp2040-bldc-motor-controller-new
A USB‑C PD–powered RP2040 BLDC motor controller PCB with 3.3 V logic, MCT8329A sensorless commutation, three MOSFET half-bridges, protected power switching, USB data, controls, and motor connectors.
- Version
- 0.3.82
- License
- unset
- Stars
- 0
scripts/pcb-audit/geometry.py
import os
from pathlib import Path
import shapely
from shapely.geometry import Point,LineString,Polygon,box
BASE=Path(os.environ.get("PCB_AUDIT_OUTPUT",Path(__file__).resolve().parents[2]/"assembly/dist/results"))
BASE.mkdir(parents=True,exist_ok=True)
LAYERS=["top","inner1","inner2","bottom"]
xy=lambda q:(q["x"],q["y"])
def padshape(p):
x,y=p.get('x',0),p.get('y',0);kind=p['shape']
if kind=='polygon':return Polygon([xy(q) for q in p['points']])
if kind=='circle':return Point(x,y).buffer(p.get('outer_diameter',p.get('radius',0)*2)/2,quad_segs=32)
w,h=p.get('outer_width',p.get('width')),p.get('outer_height',p.get('height'))
if kind in ['pill','rotated_pill']:
r=min(w,h)/2;g=LineString([(x-max(0,w-h)/2,y-max(0,h-w)/2),(x+max(0,w-h)/2,y+max(0,h-w)/2)]).buffer(r,quad_segs=32)
return shapely.affinity.rotate(g,p.get('rect_ccw_rotation',p.get('ccw_rotation',0)),origin=(x,y))
return shapely.affinity.rotate(box(x-w/2,y-h/2,x+w/2,y+h/2),p.get('rect_ccw_rotation',p.get('ccw_rotation',0)),origin=(x,y))