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: Find magnitude of a perimeter?

Previous Thread :: Next Thread 
MrMcAero is not online. 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 is not online. 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
noobertuber is not online. noobertuber
Joined: 16 Jan 2007
Total Posts: 2321
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
09 May 2012 05:45 PM
Just push them back some using CFrame.
Report Abuse
MrMcAero is not online. 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 is not online. 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
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