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 » Scripters
Home Search
 

Re: Wanted to try something more advanced ...

Previous Thread :: Next Thread 
woot3 is not online. woot3
Joined: 10 Nov 2008
Total Posts: 3599
04 Feb 2013 01:35 PM
I wanted to write a script that creates a triangle (using two wedge parts) between 3 points.

Currently, I am working in 2D as it's a little simpler, but I am then moving to 3D.
I guess I'm asking a question, I want to calculate the height of the triangle, even if it's at an angle. Have I got the math to do so correctly?

function createTriangle(a, b, c)
local ab = (a-b).magnitude
local abx = (b.x-a.x)
local bc = (b-c).magnitude
local bcx = c.x-b.x
local anga,angb = math.asin(bcx/bc),math.asin(abx/ab)
local anga,angb = anga < 0 and anga*-1 or anga, angb < 0 and angb*-1 or angb
local angc = math.pi-(anga+angb)
local h = bc*math.sin(angc)
print(h)
end

createTriangle(Vector3.new(0,0,0),Vector3.new(5,0,0),Vector3.new(4,5,0))
Report Abuse
TeamDman is not online. TeamDman
Joined: 04 Dec 2009
Total Posts: 897
04 Feb 2013 01:44 PM
Didn't Stravant make something to do the same thing?

"Don't believe everything you read online" - Abraham Lincoln
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
04 Feb 2013 01:52 PM
@Team

But all the other implementations broke down somewhere...
Report Abuse
woot3 is not online. woot3
Joined: 10 Nov 2008
Total Posts: 3599
04 Feb 2013 01:56 PM
That's actually a great help, I'll study his script.
I appreciate it!
Report Abuse
HotThoth is not online. HotThoth
Forum Moderator
Joined: 24 Aug 2010
Total Posts: 1176
04 Feb 2013 02:39 PM
Just use linear algebra-- keeps the math a lot simpler, and everything with vectors is happy in ROBLOX anyways. Seriously, though, dot product is magical-- X dot Y gives you the length of X's "shadow" when projected perpendicularly onto Y. This lets you do a lot of cool/tricky things very quickly.

So with triangle ABC and you want to find perpendicular from B down to AC, you could just do the following:

AB = B - A
AC = C - A
D = (AB:Dot(AC) * AC.unit) + A

Where D is the point on AC where B drops down to to form a right angle. So the height vector would be BD = B - D, with height of BD.magnitude.


I did this pretty quickly; may have made a mistake, but I think that's right.


- HotThoth

~ Think happy Thoths ~
Report Abuse
Alureon is not online. Alureon
Joined: 15 Dec 2012
Total Posts: 134
04 Feb 2013 03:34 PM
not advanced noob learn to script
Report Abuse
testedmarkel62 is not online. testedmarkel62
Joined: 25 Nov 2009
Total Posts: 4291
04 Feb 2013 03:53 PM
^
I'd like to see some of your work.
Report Abuse
Alureon is not online. Alureon
Joined: 15 Dec 2012
Total Posts: 134
04 Feb 2013 04:04 PM
print("some of my work. you know, i wrote the original print function in C that is still used by ROBLOX today? ask any admin.")
Report Abuse
BenBonez is not online. BenBonez
Joined: 29 Aug 2008
Total Posts: 19362
04 Feb 2013 04:07 PM
@Alureon

go away skid
Report Abuse
jordan4762 is not online. jordan4762
Joined: 08 Sep 2008
Total Posts: 4116
04 Feb 2013 04:10 PM
@Alureon
Because C functions are SO hard...

GOBWEY
Report Abuse
Alureon is not online. Alureon
Joined: 15 Dec 2012
Total Posts: 134
04 Feb 2013 04:24 PM
y'all are too easy.
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
04 Feb 2013 04:28 PM
@alur
without raging, we all have no respect for you. you're a lying idiot who can't script properly much less make a hax. go away
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
04 Feb 2013 05:41 PM
Here's one I made a while ago.
http://www.roblox.com/Triangle-Tool-item?id=34109637

If I recall correctly, it uses no trigonometry. Avoiding trig will make things so much easier for you. One thing it did was construct a CFrame using the 3x3 rotation matrix. You should look into that.

And one thing to note (this is useful when making your rotation matrix), if you have the lookVector of the front side and the lookVector of the top side, to get the lookVector of the right side, just do frontVector:Cross(topVector).
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
04 Feb 2013 05:44 PM
Learn vector notation and operations, they helpz.

Visual to learn:
-Hat thing
-Dot product
-Cross product
-Double absolute value looking thing
-Stuff
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
04 Feb 2013 05:48 PM
> And one thing to note (this is useful when making your rotation
> matrix), if you have the lookVector of the front side and the
> lookVector of the top side, to get the lookVector of the right side,
> just do frontVector:Cross(topVector).

I figured out the following myself a very long time ago. I will share with you this golden piece of knowledge:
local x,y,z,xx,yx,zx,xy,yy,zy,xz,yz,zz=CFrame:components()
position=x,y,z
right "lookVector"=xx,xy,xz
upward "lookVector"=yx,yy,yz
front "lookVector"=zx,zy,zz

k
Report Abuse
kirkyturky12 is not online. kirkyturky12
Joined: 30 Apr 2010
Total Posts: 1915
04 Feb 2013 05:56 PM
@Monkey

local X,Y,Z = CFrame.X,CFrame.Y,CFrame.Z
local X2,Y2,Z2 = CFrame:toEulerAnglesXYZ()

This will give you the angles of the CFrame. I am sure you already knew this, but oh well. :3
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
04 Feb 2013 06:00 PM
eww
Why would you want angles e.e
Report Abuse
kirkyturky12 is not online. kirkyturky12
Joined: 30 Apr 2010
Total Posts: 1915
04 Feb 2013 06:02 PM
Angles are way more useful than lookvectors. Well, in my opinion they are.
Report Abuse
kirkyturky12 is not online. kirkyturky12
Joined: 30 Apr 2010
Total Posts: 1915
04 Feb 2013 06:02 PM
Angles are way more useful than lookvectors. Well, in my opinion they are.
Report Abuse
kirkyturky12 is not online. kirkyturky12
Joined: 30 Apr 2010
Total Posts: 1915
04 Feb 2013 06:03 PM
Daheck? It double-posted...
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
04 Feb 2013 07:31 PM
eww... stop... what on earth could you use the angles for!?
Report Abuse
Alureon is not online. Alureon
Joined: 15 Dec 2012
Total Posts: 134
05 Feb 2013 10:30 AM
@booing
same thing to you sir.
Report Abuse
BlakTankerCvC is not online. BlakTankerCvC
Joined: 31 Jan 2013
Total Posts: 586
05 Feb 2013 11:31 AM
wth is a skid
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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