Jump to content

Math problem drawing a circle with lines (filled)

Featured Replies

Hey guys,

 

I'm currently building a terrain editor for a mmorpg. The program will allow me and my dev team to modify the height maps, textures, and splats in realtime. I'm having some trouble creating a perferct circle shape for the terrain "brush". Here is my code and a screenie of the shape I'm getting. Does anyone see anything obviously wrong with my furmula? This has been driving me nuts all day...

 

Public Sub deformterrain(ByVal pointsize As Integer, ByVal pointheight As Single, ByVal mx As Single, ByVal my As Single, ByVal mz As Single, ByVal shape As Boolean)

 

Dim ps As Integer

ps = pointsize / 2

Pick = land(0).MousePick(mx, my)

If Pick.IsCollision = True Then

ImpactX = Pick.GetCollisionImpact.x

ImpactZ = Pick.GetCollisionImpact.z

ImpactY = land(0).GetHeight(ImpactX, ImpactZ)

End If

 

Dim fnlx As Integer

Dim fnlz As Integer

Dim theta As Single

Dim dtheta As Single

 

dtheta = 2 * Math.PI / pointsize

theta = 0

For fnlz = -ps To ps

theta = theta + dtheta

For fnlx = ImpactX - pointsize To ImpactX + pointsize

land(0).SetHeight(fnlx + pointsize * Math.Cos(theta), ImpactZ + pointsize * Math.Sin(theta), ImpactY + pointheight, True, True)

Next

Next

land(0).FlushHeightChanges()

 

End Sub

 

circleprob.jpg

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.