MrMcAero
|
  |
| Joined: 21 Apr 2012 |
| Total Posts: 671 |
|
|
| 09 May 2012 04:40 PM |
So let's say I have to variable's:
center = (0,0,0) -- Center of the circle outFromCenter = 150 -- In stud's, this is the radius (center to circumference)
How could I get the magnitude of the circumference to the center? (Even though there are no points on the circumference)
Anyone got an equation to this? :\
- Cheers! |
|
|
| Report Abuse |
|
|
ZizZazZuz
|
  |
| Joined: 16 Jun 2008 |
| Total Posts: 2743 |
|
|
| 09 May 2012 04:41 PM |
| I don't understand... Isn't 150 already the magnitude? |
|
|
| Report Abuse |
|
|
|
| 09 May 2012 04:43 PM |
Circumference is 2*pi*radius. I'm not sure if that's what you want though...
God Bless, Noobertuber |
|
|
| Report Abuse |
|
|
MrMcAero
|
  |
| Joined: 21 Apr 2012 |
| Total Posts: 671 |
|
|
| 09 May 2012 04:44 PM |
Basically this is what i'm trying to do.
I have a circle, represented by ( ), inside the circle is a part (N), if part N goes to the circumference of that circle (The edge/the outside perimeter) it will stop moving. It's basically a wall.
I need to do something like this:
cP = game.Workspace.centerPart.magnitude nP = game.Workspace.MovingPart.Part.magnitude --Moving Part is a model nPm = game.Workspace.MovingPart
if (nP>cP) then nPm:MoveTo() -- The place it was before I tried exiting the circle end
- Cheers! |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 09 May 2012 04:46 PM |
if (MovingPartPoint-centerPartPoint).magnitude>radius_of_circle then --your stuff here end
Is that all you wanted? |
|
|
| Report Abuse |
|
|
Aerideyn
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 1882 |
|
|
| 09 May 2012 04:46 PM |
i think you have your terms wrong,
diameter is from one side of the circle to the other. radius is the distance from the center to any point on the surface of the circle.
circumfrence is the distance -around- the circle, think the equator on the earth for example.
a point on the circumfrence is always an equal distance(magnitude) from the center of the circle as it is simply the radius.
|
|
|
| Report Abuse |
|
|
MrMcAero
|
  |
| Joined: 21 Apr 2012 |
| Total Posts: 671 |
|
|
| 09 May 2012 05:39 PM |
@SDuke,
Basically what CM32 did. How can I in the "--your sutff here" area block my part from moving outside the circle?
- Cheers! |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 09 May 2012 05:45 PM |
| Just push them back some using CFrame. |
|
|
| Report Abuse |
|
|
MrMcAero
|
  |
| Joined: 21 Apr 2012 |
| Total Posts: 671 |
|
|
| 09 May 2012 06:05 PM |
Okay, well, i'm using lookVector and such to control movement of the part (CFrame whilst using lookVector). Should I use the same equation but using a neg sign to back it up? Let's see.. (Please excuse the name of part's and NO defining of the part name's, this is coming straight from my code...(It's the S "backwads" key for my code)
FakeCam.CFrame = FakeCam.CFrame - (FakeCam.CFrame.lookVector*1)
I'd use that for backing it up by 1?
- Cheers! |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 09 May 2012 09:41 PM |
Try something like
local unit=(center-FakeCam.CFrame.p).unit; FakeCam.CFrame=CFrame.new(unit*(radius-1))*(FakeCam.CFrame-FakeCam.CFrame.p);
That should do it. |
|
|
| Report Abuse |
|
|