[Closed] Calculating pos to create points
I’ve gone ahead and combined what you had done with what I had.
I’m checking out how you went about doing the math. It’s so simple and i never looked at it that way. Very impressive and super clean. Makes sense now that I’ve checked out what you wrote and messed around with the code.
Next I just need to adjust the alignment of the strands so the first point is outer most point like I mentioned above.
delete objects
columns = 4
columnAngle = 360.0 / columns as float
columnsRadius = (units.decodevalue "12cm")
strands = 1
strandAngle = 360.0 / strands as float
strandsRadius = (units.decodevalue "3cm")
for i = columnAngle to 360 by columnAngle do
(
p = point pos:[cos i * columnsRadius, sin i * columnsRadius,0] size:2 wirecolor:(if mod i 90==0 then green else red)
for i = strandAngle to 360 by strandAngle do
(
point pos:([cos i * strandsRadius, sin i * strandsRadius,0]+p.pos) size:0.5 wirecolor:(if mod i 90==0 then yellow else orange)
)
)
here we go
delete objects
columns = 3
columnAngle = 360.0 / columns as float
columnsRadius = (units.decodevalue "12cm")
strands = 3
strandAngle = 360.0 / strands as float
strandsRadius = (units.decodevalue "3cm")
clearlistener()
for c = columnAngle to 360 by columnAngle do
(
p = point pos:[cos c * columnsRadius, sin c * columnsRadius,0] size:2 wirecolor:(if mod c 90==0 then green else red)
for i = strandAngle to 360 by strandAngle do
(
x = (cos (i+c)) * strandsRadius
y = (sin (i+c)) * strandsRadius
point pos:([x, y,0]+p.pos) size:0.5 wirecolor:(if mod i 90==0 then yellow else orange)
)
)
no solution here, but its fun to make pretty patterns with math
delete objects
dist = 40
mdist = 10
m = 45
for i = m to 360 by m do
(
p = sphere pos:[cos i * dist, sin i * dist,0] radius:1 wirecolor:yellow
for i = m to 360 by m do
(
cp = sphere pos:([cos i * mdist, sin i * mdist,0]+p.pos) radius:0.5 wirecolor:yellow
for i = m to 360 by m do
sphere pos:([cos i * mdist/3., sin i * mdist/3.,0]+cp.pos) radius:0.5 wirecolor:yellow
)
)
fn clonePoints node sides depth:1 init:(matrix3 1) radius:10 wirecolor:orange radiusDecay:0.5 scaleDecay:0.7 colorDecay:0.7 = if depth > 0 do
(
tm = transmatrix [radius,0,0]
in node for k=0 to sides-1 do
(
n = copy node transform:((rotatez (copy tm) (360./sides*k))*init) wirecolor:wirecolor
clonePoints n sides depth:(depth-1) init:(prescale n.transform ([1,1,1]*scaleDecay)) radius:(radius*radiusDecay) wirecolor:(wirecolor*colorDecay) \
radiusDecay:radiusDecay scaleDecay:scaleDecay colorDecay:colorDecay
)
)
(
delete objects
gc()
p = point size:2 constantscreensize:off
initRadius = 10
clonePoints p 5 depth:4 radius:10
)
How can I move an object along a vector created from two points in 3D space. Placing the new object at a starting distance of the second object with an added offset distance of X.
In this example script I want to place the green helper 10 units from the lightblue helper, but in the direction of a vector created between the lightblue/blue helpers.
John
(
delete objects
clearlistener()
/* Create Corner Points */
startPt = point pos:([random -10 10,random -10 10,random 0 10]) wirecolor:blue size:4
endPt = point pos:([random -30 30,random -30 30,random 0 30]) wirecolor:[0,255,255] size:4
nvec = (normalize startPt.pos)
d = (distance endPt.pos startPt.pos)
point pos:(nvec*(d)) size:2 wirecolor:green
)
The end part should be
nvec = normalize (startPt.pos - endPt.pos)
point pos:(endPt.pos + nvec * 10) size:2 wirecolor:green
if I got your description right. There’s a really good chapter in maxscript reference about vectors and how to handle them, normalizing one position only would give you a direction from origin to the position.
Thank you for your help
I’ll have to find where that is and read up on it as I’m using them more and more.
Some relevant sections are Trigonometric Functions, Vector Arithmetic and Working with Vectors.