Angle correction note: GPT10_angle_correction_ver2.pro 1.Finite distance of camera to the track 2.Light ray distortion caused by refraction 3.Divergence of light ray caused by the curved surface 4.Chain length consideration Constants: d=3mm->track width, d2=1.2mm->wall width r=110.8mm->radius of track, l=727.3mm->distance from camera to center of track s=1.2mm->radius of the sphere n=1.49 ->refractive index of acrylic Inputs: angle1, angle2 (two ends of the chain) and phase (front side or back side of the track) Output: angle1β,angle2β Code: ;Jia wrote on 20160727 ;input angle is the two end of the chain got by camera ;Two ends are handled separately ;d=track width;d2=wall wedth;r=radius of the track ;l=distance of camera to the center of the track ;s=radius of the sphere;n=refractive index of acrylic ;phase=+1:front side of track;-1:back side of track ;output:(angle1',angle2') function GPT10_angle_correction_ver2,angle1,angle2,phase d=3 & r=110.8 & l=727.3 & s=1.2 & d2=1.2 & n=1.49;constants ;let angle1>angle2 if abs(angle2) gt abs(angle1) then begin a=angle1 & angle1=angle2 & angle2=a end angle=[angle1,angle2] if phase eq 1 then theta=asin(r*sin(angle)/l)+angle if phase eq -1 then begin tempt=(r^2+l^2-2*r*l*cos(!pi-angle))^0.5 theta=asin(l*sin(!pi-angle)/tempt) end ;light ray distortion cause by refraction phi=asin(sin(theta)/n) dphi=d2*tan(phi)/r theta2=asin(n*sin(phi+dphi)) ;divergence cause by the curved surface dtheta=((d+d2)*tan(theta)-d2*tan(phi)-d*tan(theta2))/r theta=theta2+dtheta ;do the iteration again: phi=asin(sin(theta)/n) dphi=d2*tan(phi)/r theta2=asin(n*sin(phi+dphi)) dtheta=((d+d2)*tan(theta)-d2*tan(phi)-d*tan(theta2))/r theta=theta2+dtheta angle(0)=angle(0)-(d/2+s*tan(abs(theta(0))/2))*tan(theta(0))/r angle(1)=angle(1)-(d/2-s*tan(abs(theta(1))/2))*tan(theta(1))/r return,angle end 1.Finite distance of camera to the track We get the rough estimation of π first. Phase = +1 Phase = β1 π r Input angle Input angle r π l π sin(πΌπππ’π‘) π = sinβ1 ( ) π lβ l lβ= π 2 + π 2 β 2 cos(π β ππππ’π‘) π= π sin(π β ππππ’π‘) ) πβ² sinβ1 ( 2.Light ray distortion caused by refraction Then, we start correcting π. We calculate the distortion of refraction with Snellβs Law, and the refractive index of acrylic is around 1.49: π= d sinβ1( ππ = πβ² sin π ) 1.49 π2 tan π π πβ² = sinβ1 (π sin(π + ππ )) π π + ππ π d2 3.Divergence of light ray caused by the curved surface It should be the angle difference between blue line and red line. But for simplification, we only concern the angle difference between blue line and black line. ππ d πβ² π π d2 π + π2 tan π β π2 tan π β π tan πβ² ππ = π We got the correction of π οΌπ = π β² + ππ, and redo 2-3 again to get a more accurate π. 4.Chain length consideration Corrected angle Input angle Corrected angle1=Input angle1β Corrected angle2=Input angle2β π 2 d s π π π ( +π tan 1 ) tan π1 2 2 π π π ( βπ tan 2 ) tan π2 2 2 π Plus and minus corresponds to two ends of the chain. And the final output is the average of the 2 corrected angle. Errors canβt correct: π ( β π ) tan π 2 π We suppose the chain always stays in the center of the track, but the deviation will cause errors.
© Copyright 2026 Paperzz