Thats my way of getting a image:

lets just look it up for 1 point (Code is VB.net)

1.) Origin.the rotationpoint from the pan-servo is 0,0,0 (X,Y,Z) or 0,0(R,Angle)

2.) Where´s your scanned point.for example the pan servo is at 50° and the tilt servo at 30°. your reading a analog value of lets say 100.

so first convert the analog value to distance:

` Public Function ADWtoDist(ByVal ADW As Integer) As String`

'If the Value is smaller as 38, the result would be biger as 300cm, what makes no sense.

If ADW < 38 Then ADW = 38

ADWtoDist = 10565 * ADW ^ -0.982

'Debug.Print("Dist: " & ADWtoDist & " cm")

End Function

3.) then we convert the polar coordinates into cartesian:Basics:

http://www.euclideanspace.com/maths/geometry/space/coordinates/polar/index.htmin Code it looks like this:

` Public Function PolarToCartesian(ByVal TiltAngle As Double, ByVal PanAngle As Double, ByVal R As Double) As Array`

'This will be 1=X,2=Y,3=Z

Dim Result(3) As Double

'Basic: http://www.euclideanspace.com/maths/geometry/space/coordinates/polar/index.htm

' x = r sin(a1) cos(a2)

' y = r sin(a1) sin(a2)

' z = r cos(a1)

'

'Where a1 = TiltAngle, a2 = PanAngle, r = R

'All Angles must be Radians, and they must be 0-180, not 0-155

TiltAngle = TiltAngle * 180 / 155

PanAngle = PanAngle * 180 / 155

TiltAngle = Math.PI * TiltAngle / 180.0

PanAngle = Math.PI * PanAngle / 180.0

'Now they can be calculatet:

Result(1) = (R * Sin(TiltAngle) * Cos(PanAngle)) + TextBox1.Text

Result(2) = (R * Sin(TiltAngle) * Sin(PanAngle)) + TextBox2.Text

Result(3) = R * Cos(TiltAngle)

Return Result

End Function

the 0-155 to 1-180 conversion comes from my servos, if you move them from 0-155 they make already 0-180 degrees...

4.) And know this must be saved into a file!Easiest format is obj:

http://en.wikipedia.org/wiki/Objexample file from my scan:

`v 31.9121705541201 33.5715843563032 17.1546264824741`

v 33.984405250283 35.7515740185642 17.1399861761586

v 36.1267443214351 38.0053134414284 17.037524539716

v 32.3026021291672 33.9823181399808 14.1901570731361

v 32.4941081567727 34.1837823666023 13.2370150128776

v 32.8076369704424 34.5136144912581 12.3293085742347

v 32.8370021129878 34.544506603671 11.3148117078009

v 32.4527234486948 34.1402456784305 10.1785760817876

to do that in Code:

` `

Dim Cartesian(3) As Double

Cartesian = PolarToCartesian(Tilt, Pan, Dist)

Dim OutStr, OutStr2, X, Y, Z, As String

OutStr = Nothing

X = Replace(Cartesian(1).ToString, ",", ".")

Y = Replace(Cartesian(2).ToString, ",", ".")

Z = Replace(Cartesian(3).ToString, ",", ".")

'This is the obj String:

OutStr2 = "v " & X & " " & Y & " " & Z & vbCrLf

RichTextBox2.AppendText(OutStr2)

5.) and at the end of a scan save it to a .obj file:`RichTextBox2.SaveFile("N:\Programme\Meshlab\ArduinoScan.obj", RichTextBoxStreamType.PlainText)`

now just open this .obj file in Meshlab, and your ready to run

6.) Meshlablook here:

http://philohome.com/scan3d/scan3d.htmunder "3D reconstruction" theres a perfect description on how to use Meshlab!

designer2k2