generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Curving a line from Point A to B?

Previous Thread :: Next Thread 
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
17 Nov 2011 12:51 PM
Alright, so I'm not so good with trig or all that fun stuff in math. So let's say I have two points:

A (-100, 0)
B (100, 0)

Using a 'for' loop, how would I find each point between A and B of which creates a curved line? The angle or amount of the curve can be whatever, since I don't know how to clarify that, due to the fact that I have no idea how to go about doing this at all.

In simpler terms, I want to make a 'u' or 'n' shaped arc between points A and B.
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
17 Nov 2011 01:19 PM
I think you should just get the midle point (wich is 0,0 here) then the radius is 100.
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
17 Nov 2011 01:22 PM
So you know, making a circle with the midle point A+B/2 then the diameter is A + B so the radius is from midle point to either A or B, therefore the radius is 100.
Report Abuse
sdfgw is not online. sdfgw
Top 50 Poster
Joined: 08 Jan 2009
Total Posts: 41681
17 Nov 2011 01:32 PM
Depends. You could use a third point and use linear interpolation (I think, I don't know this) or make a quadratic bezier thingy (I think, I don't know this)

Explain moar about the context.
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
17 Nov 2011 01:39 PM
*slaps sdfgw*

No Wall-E maths plz.
Report Abuse
yoyoman2 is not online. yoyoman2
Joined: 07 Mar 2009
Total Posts: 2170
17 Nov 2011 02:15 PM
like a math function?
f(y) = ax + b

this will make a line will be curved by a and the b is the point where the line hits the y axis

so you can do this:
y - y
____ = a
x - x

i think
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
17 Nov 2011 02:28 PM
@sdfgw - Yeah, adding a center point would be ideal.

So say point AB = (0, 100)
Report Abuse
sdfgw is not online. sdfgw
Top 50 Poster
Joined: 08 Jan 2009
Total Posts: 41681
17 Nov 2011 02:40 PM
mk, you could try a quadratic through it - this would be ideal if you were trying to imitate, say, the path of a ball flying through the air. Otherwise I'm pretty sure you'd use linear interpolation, which I'm hoping will be explained by a kind passer-by soon.
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
17 Nov 2011 02:54 PM
Didn't exactly get it, but found this. Might help you:
en(dot)wikipedia(dot)org/wiki/Interpolation

Replace (dot) with '.'
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
17 Nov 2011 02:54 PM
And would you mind explaining it to me if you understand it? Please?
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
17 Nov 2011 02:55 PM
But why don't you just use my circle epicness?
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
17 Nov 2011 02:56 PM
Cause we all know that whatever you make never works. [/jk]
Report Abuse
DangCool is not online. DangCool
Joined: 27 Apr 2010
Total Posts: 5568
17 Nov 2011 03:06 PM
[ Content Deleted ]
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
17 Nov 2011 03:07 PM
LOL, crazyman32's post :P
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
17 Nov 2011 03:08 PM
@Dang: Just testing my F5 bot in C++...UJELLY BRUH? :P
Report Abuse
DangCool is not online. DangCool
Joined: 27 Apr 2010
Total Posts: 5568
17 Nov 2011 03:10 PM
[ Content Deleted ]
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
17 Nov 2011 03:14 PM
10k views? Alright then
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
17 Nov 2011 03:19 PM
You can use sin/cos to make the curve, and use derivatives to smooth it out.

http://wiki.roblox.com/index.php/Derivatives
Report Abuse
bob354293 is not online. bob354293
Joined: 26 Oct 2008
Total Posts: 2609
17 Nov 2011 04:00 PM
woahh, you could try this;

x = 100

for i = 1,100 do
local part = Instance.new("part") --Or however you insert a part
part.name = "Part"
part.Size = (10,2,2) -- or whatever size you want it :p
part.Position = (0,X,0) --or whatever the dimensions are
wait()
x = x+1
end

this would insert the parts, idk about cframing them around :p
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
17 Nov 2011 04:46 PM
OMG, dude...
crazyman32, what about making a sort of grid from point 'A' to point 'B'. Then you can use a linear function to make the 'U'/'n' shaped curve.
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
17 Nov 2011 05:14 PM
Hmm...maybe this was way easier than I though haha
Report Abuse
bob354293 is not online. bob354293
Joined: 26 Oct 2008
Total Posts: 2609
17 Nov 2011 05:16 PM
crazyman, 1 post from you suddenly gets 11,000 views? its not a big deal that someone who can build epic games is posting in the forums, but seriously, 11000, my forum posts rarely get 20 views ....
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
17 Nov 2011 05:28 PM
Or you can do it the fun way and use a Bezier Curve :D

local w = workspace
local p1,p2 = Vector3.new(0,0,-100),Vector3.new(0,0,100)

function part(pos)
p = Instance.new("Part",workspace)
p.Anchored = true
p.Size = Vector3.new(1,1,1)
p.CFrame = CFrame.new(pos)
end

function Midpoint(pos1,pos2)
return pos1:lerp(pos2,.5) + Vector3.new(0,50,0)
end

function curve(pos1,mid,pos2)
u = (pos1 - pos2).unit
for i = 0,1,.06 do
q = (p1*((1-i)^2) + (mid*((2*i)*(1-i))) + (pos2*i^2)
part(u + q,i)
end
end

curve(p1,Midpoint(p1,p2),p2)

-[::ƧѡÎḾḠΰῩ::]-
-[::Maker of stuff and Helper of Scripting::]-
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
17 Nov 2011 06:02 PM
"a linear function"
Linear is when the line plotted is consistent (as y goes up by ... x goes up by). You're looking for non-linear.
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
17 Nov 2011 06:09 PM
My bad nate.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image