[DKR]silverfang Posted March 24, 2009 Share Posted March 24, 2009 Wiki Page Right the offset values are in X,Y and Z. I can get the offset values (relative to the parent object) by playing around with the trig functions, but that takes some time and I have yet to find a rule of thumb for it, Can someone give me a quick rundown on each (cos, sin, -cos, -sin) and explain how you would use them to position an object around another object/element. Thanks in advance (I lack the sideways thinking to work it out) Link to comment
darkdreamingdan Posted March 24, 2009 Share Posted March 24, 2009 AttachElementToElement's offset arguments are relative. This means if you want to attach an element to an element, imagine that the parent element's rotation is 0. For attaching at x -2 would attach behind the element, no matter what it's current rotation. As far as calculating this for two real world positions - it gets a little more complicated. Trigonometry only allows for taking into account two axes. This is fine if, for example, the Z offset is always 0. If you want to calculate a relative argument on all 3 axes, you'll have to use quatornion math or matrices. Link to comment
[DKR]silverfang Posted March 25, 2009 Author Share Posted March 25, 2009 Would you care to explain in a little more detail what "quatornion (quaternion?) math and matrices" do in order to move it around the object. Thanks Link to comment
Slothman Posted March 26, 2009 Share Posted March 26, 2009 its another word for witchcraft. you will all burn for you maths! Link to comment
Extremo Posted March 29, 2009 Share Posted March 29, 2009 Well according to that you want to know how to place a object around a object cosinus and sinus are no good choice. They always require at least two given sides and regarding to your request its basically not the right form? If you are trying to place a object like: :: object :: :: object :: :: object :: :: object :: Then its a perfect choice to use sinus and cosinus, but if i got you right you want to basically do this: :: b i g O ::smallobject:: b :: t c e j Right? If not, could you at least draw a example or anything? it would help. Link to comment
[DKR]silverfang Posted March 29, 2009 Author Share Posted March 29, 2009 I don't really Understand what you said. Hope the image helps... Link to comment
Extremo Posted March 30, 2009 Share Posted March 30, 2009 Well, all i can see from your picture is that the object should be on a different position and i am not sure how you want to calculate that? Why not getting the position of the first object and adjusting these, then creating the next one? Sorry but i dont get your image either lol. Link to comment
Lordy Posted March 31, 2009 Share Posted March 31, 2009 You can use just trig to calculate x-y positions and then just set z, can't you? OB would be the distance and the corner would be the degrees you want. If you attach to player, I think they are relative values so the player faces upwards in y direction. (Like being in 0,0,0, rotation 0). And there you have a nice triangle. [attachment=0]trig.png[/attachment] x_offs = math.sin(math.rad(corner)) * OB y_offs = math.cos(math.rad(corner)) * OB z_offs = somerandomnumber attachElement(theElement, theAttachToElement, x_offs, y_offs, z_offs, x_rot_offs, y_rot_offs, z_rot_offs) That isn't so hard Note however that math.sin and math.cos operate in radians iirc so you have to convert them before using (with math.rad) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now