\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Ozzypig (Ozzypig)} \pdfinfo{ /Title (roblox-cframes.pdf) /Creator (Cheatography) /Author (Ozzypig (Ozzypig)) /Subject (Roblox: CFrames Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{DE302A} \definecolor{LightBackground}{HTML}{FCF2F1} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Roblox: CFrames Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Ozzypig (Ozzypig)} via \textcolor{DarkBackground}{\uline{cheatography.com/25526/cs/10637/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Ozzypig (Ozzypig) \\ \uline{cheatography.com/ozzypig} \\ \uline{\seqsplit{ozzypig}.com} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 24th January, 2017.\\ Updated 24th January, 2017.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{What is a CFrame?}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{A {\bf{CFrame}} is a mix of a position and rotation. CFrames are used to define the position/orientation of bricks, cameras, and many other objects in Roblox places. Think of them as paper airplanes that are frozen in time. They are different from \{\{link="http://wiki.roblox.com/index.php?title=Vector3"\}\}Vector3s\{\{/link\}\} and \{\{link="http://wiki.roblox.com/index.php?title=Ray"\}\}Rays\{\{/link\}\}.% Row Count 8 (+ 8) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Math involving CFrames isn't as difficult as you might think, but you must understand what's going on behind the code!} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Constructors}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}`CFrame.new()`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Identity CFrame at (0, 0, 0) facing forward.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}`CFrame.new({\bf{Vector3}} v3)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}CFrame at Vector3 facing forward.} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}`CFrame.new({\bf{Vector3}} pos, {\bf{Vector3}} target)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}CFrame at Vector3 \{\{nobreak\}\}`pos` facing Vector3 \{\{nobreak\}\}`target`.} \tn % Row Count 8 (+ 4) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}`CFrame.new(x, y, z)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}CFrame at (x, y, z) facing forward.} \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}`CFrame.new(x, y, z, qX, qY, qZ, qW)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}CFrame at (x, y, z) with quaternion (qX, qY, qZ, qW).} \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}`CFrame.new(x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}CFrame at (x, y, z) with given rotation matrix.} \tn % Row Count 16 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}`CFrame.Angles(rX, rY, rZ)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}CFrame at (0, 0, 0) rotated with \{\{link="http://wiki.roblox.com/index.php?title=Euler\_angles"\}\}Euler angles\{\{/link\}\} (rX, rY, rZ) in {\bf{radians}}.} \tn % Row Count 21 (+ 5) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}`CFrame.fromAxisAngles({\bf{Vector3}} unit, {\bf{number}} rotation)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Rotated CFrame from unit Vector3 and a rotation in {\bf{radians}}.} \tn % Row Count 25 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{All of these return a new {\bf{CFrame}} value. Unless otherwise specified, parameters are {\bf{numbers}}.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Operators}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}`{\bf{CFrame}} * {\bf{CFrame}}`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Return the composition of two CFrames.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}`{\bf{CFrame}} * {\bf{Vector3}}`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Returns Vector3 transformed from Object to World coordinates.} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}`{\bf{CFrame}} + {\bf{Vector3}}`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Return CFrame translated in world space by Vector3.} \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}`{\bf{CFrame}} - {\bf{Vector3}}`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Return CFrame translated in world space by negative Vector3.} \tn % Row Count 11 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Remember that {\bf{order matters}}! This means that if you flip the values you will get a different value. These expressions give two different results:\{\{nobreak\}\}\{\{nl\}\}`cf * cf2\{\{nl\}\}cf2 * cf`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Object space versus World space?}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{When working with CFrames, we often talk about {\bf{object}} versus {\bf{world}} space. What we're really talking about is {\bf{relativity}}. Everything has a position that is relative to everything else. Object space is a way of saying "relative to {\emph{this}} CFrame". World space is a way of saying "relative to the origin", or (0, 0, 0).% Row Count 7 (+ 7) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{This terminology is most often used in method documentation. Use it when trying to code up solutions to CFrame math problems. For example, might you want to transform a Vector3 that you know to be relative to something else (object space) into world space. In that case, you would use \{\{nobreak\}\}`brick.CFrame:toWorldSpace(v3)`.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Properties}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Property}} & {\bf{Description}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \{\{nobreak\}\}{\bf{Vector3}}~`p` & The 3D position of the CFrame. \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{number}}~`x` & The x-component of the Vector3 position. \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \{\{nobreak\}\}{\bf{number}}~`y` & The y-component of the Vector3 position. \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{number}}~`z` & The z-component of the Vector3 position. \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} \{\{nobreak\}\}{\bf{Vector3}}~`lookVector` & The forward-direction component of the CFrame's orientation. \tn % Row Count 12 (+ 3) % Row 6 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{Vector3}}~`rightVector` & The right-direction component of the CFrame's orientation. \tn % Row Count 15 (+ 3) % Row 7 \SetRowColor{white} \{\{nobreak\}\}{\bf{Vector3}}~`upVector` & The up-direction component of the CFrame's orientation. \tn % Row Count 18 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{These properties are all {\bf{read-only}}, meaning they can be read from, but not changed. This is called {\bf{immutability}}.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Methods}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}{\bf{CFrame}}~`cf:inverse()`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Returns the inverse of this CFrame.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}{\bf{CFrame}}~`cf:lerp({\bf{CFrame}} goal, {\bf{number}} alpha)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Returns a CFrame interpolated between this CFrame, and the goal CFrame by the fraction alpha.} \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}{\bf{CFrame}}~`cf:toWorldSpace({\bf{CFrame}} cf2)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Returns a CFrame transformed from Object to World coordinates. Equivalent to \{\{nobreak\}\}`cf * cf2`} \tn % Row Count 11 (+ 5) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}{\bf{CFrame}}~`cf:toObjectSpace({\bf{CFrame}} cf2)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Returns a CFrame transformed from World to Object coordinates. Equivalent to \{\{nobreak\}\}`cf:inverse() * cf2`} \tn % Row Count 16 (+ 5) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}{\bf{Vector3}}~`cf:pointToWorldSpace({\bf{Vector3}} v3)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Returns a Vector3 transformed from Object to World coordinates. Equivalent to \{\{nobreak\}\}`cf * v3`} \tn % Row Count 21 (+ 5) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}{\bf{Vector3}}~`cf:pointToObjectSpace({\bf{Vector3}} v3)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Returns a Vector3 transformed from World to Object coordinates. Equivalent to \{\{nobreak\}\}`cf:inverse() * v3`} \tn % Row Count 26 (+ 5) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}{\bf{Vector3}}~`cf:vectorToWorldSpace({\bf{Vector3}} v3)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Returns a Vector3 rotated from Object to World coordinates. Equivalent to \{\{nobreak\}\}`(cf - cf.p) * v3`} \tn % Row Count 31 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Methods (cont)}} \tn % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}{\bf{Vector3}}~`cf:vectorToObjectSpace({\bf{Vector3}} v3)`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Returns a Vector3 rotated from World to Object coordinates. Equivalent to \{\{nobreak\}\}`(cf - cf.p):inverse() * v3`} \tn % Row Count 5 (+ 5) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}{\bf{numbers}}~`cf:components()`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Returns the components of the CFrame in this order: x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22.} \tn % Row Count 9 (+ 4) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{nobreak\}\}{\bf{numbers}}~`cf:toEulerAnglesXYZ()`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Returns the {\emph{best guess}} angles that could be used to generatea CFrame using \{\{nobreak\}\}`CFrame.Angles`. See \{\{link="http://wiki.roblox.com/index.php?title=Euler\_angles"\}\}Euler angles\{\{/link\}\}.} \tn % Row Count 16 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}