Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Point , Point , Point , to Line/Curve

Author
Message
Guido Italy
19
Years of Service
User Offline
Joined: 25th Dec 2005
Location:
Posted: 11th Apr 2015 21:42
Hello Everyone!

I have this problem:

I create "points" "freehand", (I know the coordinates x, y of each of them), I must, however, as results as,
a design like the one below in the attached image.

I need a mathematical formula (or algorithm), which is able to "understand" where I wanted to draw a line and where it should be drawn a curve.

Can anyone help me?

is a very important function for Visual Jump 3D!

Thanks, and sorry for my English, Guido

Attachments

Login to view attachments
basjak
15
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 12th Apr 2015 01:24
no need to recreate the wheel again:

use Vector hermite, CattMullRom, Barrycentric, Interpolation:

Hrmite, Catmollrum are used as well in 2D graphics software to create curves.

compile the following 2 examples then use arrowkeys to see the results:





Guido Italy
19
Years of Service
User Offline
Joined: 25th Dec 2005
Location:
Posted: 12th Apr 2015 01:30
Thank ! now i test !
Guido Italy
19
Years of Service
User Offline
Joined: 25th Dec 2005
Location:
Posted: 12th Apr 2015 02:20
Re Hi ,

for first example i have change :


This

make vector2 P0
make vector2 P1
make vector2 P2
make vector2 P3
make vector2 P



to THIS

r0=make vector2( P0)
r1=make vector2 (P1)
r2=make vector2 (P2)
r3=make vector2 (P3)
r=make vector2( P)

and

ink coomand

... and the first example go !

but second example not go ...


but my problem is i've many and many point ( is very long path )

a piece of my code :


open to read 1,file$
read string 1,a$:d#=val(a$)
while file end(1)=0
StartRicreaLinea Misura=StartRicreaLineaMisura+1
read string 1,a$:GlobXmis#(StartRicreaLineaMisura)=val(a$)
read string 1,a$:Globymis#(StartRicreaLineaMisura)=val(a$)
endwhile
close file 1

all these points are drawn "free hand", and,
accordingly, are not drawn very well.

From this my piece of code, you can create a function
to redesign my track?

Thank !
basjak
15
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 12th Apr 2015 02:45
they're both work with me.

I will take vector CatMullRom as an example:

let's create 4 pointes:
P0
P1
P2
P3

now to write a correct curve between P1 and P2, you will need two power points: P0 and P3.

so every time you need to draw a curve between 2 points, you will need to know the point before the curve and after the curve.

in case of Hermite: points P1 and P3 are the power points.

Have you tried bezier curve from matrix utiliy?
With bezier curve, you can create non accurate curve between points

Guido Italy
19
Years of Service
User Offline
Joined: 25th Dec 2005
Location:
Posted: 12th Apr 2015 17:22
( Re thank )

<<Have you tried bezier curve from matrix utiliy?
With bezier curve, you can create non accurate curve between points>>

No i never used ,

but you ( please !!! ) , can you write for my code for :

n ---> is the number of the point

GlobXmis#(n)
---> Is coordinate ( in array )
GlobYmis#(n)

Thank !
Guido Italy
19
Years of Service
User Offline
Joined: 25th Dec 2005
Location:
Posted: 13th Apr 2015 19:33
some help? ( please and Thanks ) !!!
Guido Italy
19
Years of Service
User Offline
Joined: 25th Dec 2005
Location:
Posted: 13th Apr 2015 20:20
I do not think you understand exactly what is my problem ...
I have now made my design more understandable
(Attached to this post)

Help me , THANKS !!

Attachments

Login to view attachments
basjak
15
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 14th Apr 2015 12:14
Hello:

just got back to the forum.

maybe I can't help you in writing a full code because am really busy. but I wanted to leave a hint for you.

the Idea behind using CatMullRom is to create waves between every two points.

as you let the program create automatically middle points between the points you set, the wave becomes as higher frequency and a ticker line would be drawn.

let me know in two weeks if you couldn't do it. maybe I can have sometime for it. unless someone in the forum has some other idea. but this what would i use to create a thicker line.

Guido Italy
19
Years of Service
User Offline
Joined: 25th Dec 2005
Location:
Posted: 14th Apr 2015 21:06
Ok! thanks a lot!

if and when, you'll have time it tries to send the code.

thanks again

Login to post a reply

Server time is: 2025-05-13 13:48:49
Your offset time is: 2025-05-13 13:48:49