Hi Cloggy!
Very happy to oblige you sir.
Here is a little demonstration I've thrown together using v5.9 of how to draw a 3d circle (using your existing dot3d command):
Rem PJY - the picnic basket obsessed bear's magic 3d circle code
sync on
sync rate 60
autocam off
d3d_init
Rem PJY - make a matrix to act as a visual reference point
make matrix 1, 1000, 1000, 100, 100
position matrix 1, -500, 0, -500
Rem PJY - stick the camera somewhere useful
position camera -50, 20, -50
point camera 0, 0, 20, 0
Rem PJY - create a completely random normalised vector
Rem PJY - this is the normalised vector of the plane on which the Rem PJY - circle "sits"
null = make vector3(1)
set vector3 1, 100, 50, 30
normalize vector3 1, 1
x# = x vector3(1)
y# = y vector3(1)
z# = z vector3(1)
null = delete vector3(1)
repeat
text 0, 0, "FPS : " + str$(screen fps())
rem circle3d(r, x, y, z, nx, ny, nz)
Rem PJY - say the circle has a radius of 10
Rem PJY - that its centre point coords are x = 0, y = 20, z = 0
Rem PJY - and feed in the normalised vector
circle3d(10, 0, 20, 0, x#, y#, z#)
control camera using arrowkeys 0, 2, 1
sync
until spacekey() > 0
delete matrix 1
FUNCTION circle3d(radius as float, x as float, y as float, z as float, nx as float, ny as float, nz as float)
Remstart
r is the radius
x, y and z are the centre coords for the circle
nx, ny and nz are the dimensions of the vector that define the normal of
the plane on which the circle resides
remend
null = make vector3(1)
null = make vector3(2)
null = make vector3(3)
null = make matrix4(4)
Rem PJY - set vector3 1 to be the normalised vector
set vector3 1, nx, ny, nz
Rem PJY - we need to create a normalised vector that is within the plane
Rem PJY - in order to do that, lets calculate the nearest point within the
Rem PJY - plane from another point (which I will choose randomly)
set vector3 2, 0, 100, 0
distance# = dot product vector3(2, 1)
Rem PJY - to find the point in the plane we now just scale the normalised vector by the distance
multiply vector3 1, distance#
Rem PJY - and create a normalised vector to the point in the plane
Rem PJY - via a bit of vector math (muhahahahaha)
subtract vector3 2, 2, 1
Rem PJY - now create a normalised vector from the centre to the new point
set vector3 3, x vector3(2) - x, y vector3(2) - y, z vector3(2) - z
normalize vector3 3, 3
d3d_line3d x, y, z, x + x vector3(3), y + y vector3(3), z + z vector3(3), rgb(255, 0, 255), 1
Rem PJY - re-normalise the normal vector
set vector3 1, nx, ny, nz
Rem PJY - around and around we go, where we stop ...
for angle = 1 to 360
build rotation axis matrix4 4, 1, angle
transform normals vector3 2, 3, 4
x_circle# = x + x vector3(2)
y_circle# = y + y vector3(2)
z_circle# = z + z vector3(2)
d3d_dot3d x_circle#, y_circle#, z_circle#, 3, rgb(255, 0, 0), 1
next angle
Rem PJY - create a lovely green line to represent a somewhat longer version of the normalised vector of the circle
d3d_line3d x, y, z, x + nx, y + ny, z + nz, rgb(0, 255, 0), 1
null = delete vector3(1)
null = delete vector3(2)
null = delete vector3(3)
null = delete matrix4(4)
ENDFUNCTION
An ellipse is a bit more complex mathematically. My current code for that is a quick hack. I'd better clean it up before I post it.
Cheer if you like bears! Cheer if you like jam sandwiches!
Quote of the week: "... I started learning DBP while I was a Satellite Network Controller for the US Army Space Command ... "