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: Coordinates of Corner of Rotated Rectangular Part

Previous Thread :: Next Thread 
duckwit is not online. duckwit
Joined: 08 Aug 2008
Total Posts: 1310
19 Jun 2013 11:38 AM
I am developing some scripts to procedurally generate smooth curves for some slides using CFrame.

To make sure certain parts overlap nicely and don't leave jagged edges sticking out from any of the sides I need to be able to reference certain points in the geometry.

The slides are being constructed using an iteration sequence, so each rectangle is placed based on the CFrame of the previous one.

1. Place new Part in front of previous using lookVector * previous.Size.z (traversing z-axis)
2. Find the coordinate of the top right corner of the previous rectangle
3. Rotate the new Part around this point by a given amount

I have been struggling to articulate my mathematics to find this coordinate. I have tried using the CFrame matrix and the lookVector properties but haven't done so successfully.
How can I find the coordinate of a given corner of a rotated 3D rectangle?

TL;DR
In an axis aligned, origin-centered rectangle the coordinate of the corner I want to reference is:
(part.Position.x+0.5*part.Size.x,
part.Position.y+0.5*part.Size.y,
part.Position.z+0.5*part.Size.z)

...how can I refer to the new coordinate when the rectangle has been rotated?

Thank you very much for taking the time to help me with this!
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
19 Jun 2013 11:42 AM
Well. If you are using a CFrame, you could do a * CFrame.Angles() to fix it. Angles of the part.
Report Abuse
duckwit is not online. duckwit
Joined: 08 Aug 2008
Total Posts: 1310
19 Jun 2013 11:44 AM
To find the coordinates of the corner I tried:
defaultCorner * previous.CFrame:components()
(Where default is the part-relative corner I mentioned above)
... but that doesn't give me the corner?
Report Abuse
ArbiterOfDeath is not online. ArbiterOfDeath
Joined: 20 Jun 2011
Total Posts: 1458
19 Jun 2013 11:53 AM
local part =

local corner = Vectors.new(part.Size.X/2, part.Size.Y/2, part.Size.Z/2)

corner = part.CFrame:vectorToObjectSpace(corner)

corner = part.Position + corner
Report Abuse
duckwit is not online. duckwit
Joined: 08 Aug 2008
Total Posts: 1310
19 Jun 2013 12:13 PM
Thanks @ArbiterOfDeath, that references the corner I was after.
What I don't understand now though is that the look vector is pointing away from the positive z-axis even though it's rotation is (0,0,0)?
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
19 Jun 2013 12:21 PM
    local s = part.Size
    local c = part.CFrame
    corner = c*CFrame.new(s/2)

Report Abuse
duckwit is not online. duckwit
Joined: 08 Aug 2008
Total Posts: 1310
19 Jun 2013 12:24 PM
@1waffle1 that returns a CFrame and not a Vector3
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
19 Jun 2013 12:25 PM
    corner = (part.CFrame*CFrame.new(part.Size/2)).p
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
19 Jun 2013 12:39 PM
[ Content Deleted ]
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