Derivatives: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Mindraker
(New page: __TOC__ == Introduction == This tutorial is intended to introduce you to the mathematical notion of derivatives. == How will this page help me == This page will help smooth out your [[...)
>Mindraker
(Could someone double check this?)
Line 7: Line 7:
== How will this page help me ==
== How will this page help me ==


This page will help smooth out your [[Terrain Generation|Terrains]], if you use mathematical formulae to create them.
This page will help smooth out your [[Terrain Generation|Terrains]], if you use mathematical formulae to create them.  In ROBLOX, however, we do not work with mathematical "points", but "bricks", which occupy space.  Therefore, in order to smooth out terrains and functions, you will want to know the slopes of your functions... to know the slopes of your terrains.


[[Image:Derivative.PNG|thumb|An example of how you can use Derivatives]]
[[Image:Derivative.PNG|thumb|An example of how you can use Derivatives]]
Line 14: Line 14:


A derivative is the slope of a function, or, phrased differently, the difference in the height divided by the difference in width at that point.
A derivative is the slope of a function, or, phrased differently, the difference in the height divided by the difference in width at that point.
The [[Ramps]] article provides a method on how to rotate a brick:
<pre>
game.Workspace.slope.CFrame=CFrame.new(Vector3.new(0,100,0)) * CFrame.fromAxisAngle(Vector3.new(0,0,1), math.pi/2)
</pre>
Here we have the brick being created in its position in the first CFrame, and the rotation in the second CFrame.  This is where the derivative comes in.  In the script below, z=-x^2.  The derivative for this is -2*x, which you see in the script below.


<pre>
<pre>
Line 42: Line 50:


[http://en.wikipedia.org/wiki/Derivative Wikipedia article on Derivatives]
[http://en.wikipedia.org/wiki/Derivative Wikipedia article on Derivatives]
[[Category:Scripting Tutorials]]

Revision as of 23:49, 31 December 2008

Introduction

This tutorial is intended to introduce you to the mathematical notion of derivatives.

How will this page help me

This page will help smooth out your Terrains, if you use mathematical formulae to create them. In ROBLOX, however, we do not work with mathematical "points", but "bricks", which occupy space. Therefore, in order to smooth out terrains and functions, you will want to know the slopes of your functions... to know the slopes of your terrains.

An example of how you can use Derivatives

What is a derivative?

A derivative is the slope of a function, or, phrased differently, the difference in the height divided by the difference in width at that point.

The Ramps article provides a method on how to rotate a brick:

game.Workspace.slope.CFrame=CFrame.new(Vector3.new(0,100,0)) * CFrame.fromAxisAngle(Vector3.new(0,0,1), math.pi/2)

Here we have the brick being created in its position in the first CFrame, and the rotation in the second CFrame. This is where the derivative comes in. In the script below, z=-x^2. The derivative for this is -2*x, which you see in the script below.

x=0
z=0
for i = -2.5,2.5, .01 do
x=i
z=-x^2

p = Instance.new("Part")
p.CFrame=CFrame.new(Vector3.new(100*x+100, 100*z+100, 100))*CFrame.fromAxisAngle(Vector3.new(0,0,1), -2*x)
 
p.Size = Vector3.new(1,1,1)
p.Anchored = true
p.BottomSurface = "Smooth"
p.TopSurface = "Smooth"
p.Parent = game.Workspace
p.BrickColor = BrickColor.new(217)

end

See Also

Ramps

Terrain Generation

Wikipedia article on Derivatives