BriGhtx3 Posted June 2, 2012 Share Posted June 2, 2012 Hey! I can't figure out how to create a sphere between 2 positions (X/Y). Currently I use createColCuboid and calculate the width and depth like this: width = math.abs(x1-x2) depth = math.abs(y1-y2) But when I create a sphere with a command, the sphere sometime gets created to the wrong/opposite side. For example: I create a sphere from the station at SF to the police department, but it gets created from the station to the opposite side. Is there another function to create a sphere with two positions? Link to comment
BriGhtx3 Posted June 4, 2012 Author Share Posted June 4, 2012 I still need help.. Not even Solidsnake or Kenix? Link to comment
50p Posted June 4, 2012 Share Posted June 4, 2012 I don't understand your question to be honest. If you get wrong coords that's because you use math.abs which will always give you positive values. But still, your question is not clear. "Create sphere between 2 points" doesn't say much. Link to comment
DarkLink Posted June 4, 2012 Share Posted June 4, 2012 Correct me if I am wrong: you want to create a sphere using Dx, giving 2 coords > (x,y,z) and (x1,y1,z1) . and using this 2 coords you get the middle of the line segment, right ? that will be this point : ( (x1-x)/2 , (y1-y)/2 , (z1-z)/2 ) and using this point, you will create the sphere, with that center : ( (x1-x)/2 , (y1-y)/2 , (z1-z)/2 ) and with a given radius, depending on the distance between those points, using square root. Is that you want ? Link to comment
BriGhtx3 Posted June 4, 2012 Author Share Posted June 4, 2012 Yes you got it ;D And how do I calculate the distance now? I tried to use getDistanceBetweenPoints2D/2, but it only returns 1 float. But i need a width and depth Link to comment
DarkLink Posted June 4, 2012 Share Posted June 4, 2012 Glad to understand u I guess u need to use getDistanceBetweenPoints3D instead , and divide per 2 Link to comment
BriGhtx3 Posted June 4, 2012 Author Share Posted June 4, 2012 Just tried it^^ The problem is that (x1-x)/2 , (y1-y)/2 , (z1-z)/2 is not the center of those points But the width and height is ok now Link to comment
DarkLink Posted June 4, 2012 Share Posted June 4, 2012 Just tried it^^The problem is that (x1-x)/2 , (y1-y)/2 , (z1-z)/2 is not the center of those points But the width and height is ok now Sorry my bad, is not subtract is sum. Like this : (x1+x)/2 , (y1+y)/2 , (z1+z)/2 Try it , and say the results, if its ok Link to comment
BriGhtx3 Posted June 4, 2012 Author Share Posted June 4, 2012 Yes it works Thank you so much ) Link to comment
DarkLink Posted June 4, 2012 Share Posted June 4, 2012 No problem mate, have fun scripting 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