|
| 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
|
  |
| 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
|
  |
| 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
|
  |
 |
| 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
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 17 Nov 2011 01:39 PM |
*slaps sdfgw*
No Wall-E maths plz. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 17 Nov 2011 02:28 PM |
@sdfgw - Yeah, adding a center point would be ideal.
So say point AB = (0, 100) |
|
|
| Report Abuse |
|
|
sdfgw
|
  |
 |
| 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 |
|
|
|
| 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 |
|
|
|
| 17 Nov 2011 02:54 PM |
| And would you mind explaining it to me if you understand it? Please? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 17 Nov 2011 02:56 PM |
| Cause we all know that whatever you make never works. [/jk] |
|
|
| Report Abuse |
|
|
DangCool
|
  |
| Joined: 27 Apr 2010 |
| Total Posts: 5568 |
|
| |
|
| |
|
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
|
  |
| Joined: 27 Apr 2010 |
| Total Posts: 5568 |
|
| |
|
| |
|
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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 17 Nov 2011 05:14 PM |
| Hmm...maybe this was way easier than I though haha |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|