I'm trying to create a grid function using 4 vector3 values.

var size = 4 #This will create rows and columns 4 points long/high
var points = [Vector3(-4,-4,-4), Vector3(-4,4,4), Vector3(4,4,4), Vector3(4,-4,-4)]
#points 0 and 2 are directly across from each other, 1 and 3, making an x shape

for x in size:
	for y in size:
		CreatePointAt() #vector placed x/size and y/size distance along the grid

I think some sort of fraction is involved, multiplying by x/size and y/size or something similar. Maybe the center of all 4 points is important? (p1+ p2 + p3 + p4)/4. Potentially I could have different cases to set up the points, like if x < size/2 then use the distances of a particular 2 points instead of the ones across from each other. I am stuck.

In advance, I am sure this is how I would like to structure my code, and I dont believe gridmaps will help here. Mostly looking for help creating a formula. Any help appreciated though, thank you!

  • dizzy If points are coplanar you can use bilinear interpolation to get coordinates of any point inside a convex quadrilateral. The questions still remains - what do you need this for?

What are you using this grid for? Is it for game logic or just visual? How are you planning to display the grid? Why define it using 4 points?

Sorry for asking so many question. It's to figure out the best suggestion for your code.

    award This is for some mesh generation stuff. Logically I know that this is how I want to set it up, Ill be using the X and Y values of the 4 loops for game logic by tracking these points within an array grid [x][y]. There are multiple different grids using different sets of 4 corner points, and the points will never be flat along a single axis. I'm struggling with the math formula that can place new points between the corners using these x and y values.

    • xyz replied to this.

      dizzy This looks like an XY problem. It'd be better to describe what exactly you're trying to achieve with this.

      Apologies Ive realized in the original post that my code setting up my grid array is missing... the array, but that's not the part I'm concerned about. Here's a graphic I made trying to visualize what I want to do. I understand how to find the middle between two points in 3D space, but I'd like to find say 1/3 or 2/3 of the way between them. I need a formula that considers these 4 corner points and can plot new points between them using a variable scale.

      Edit: Also in this graphic the scale might be 3 since arrays are 0 based

      • xyz replied to this.
        • Edited
        • Best Answerset by dizzy

        dizzy If points are coplanar you can use bilinear interpolation to get coordinates of any point inside a convex quadrilateral. The questions still remains - what do you need this for?

          xyz
          You're an angel this is perfect! I might need another graphic lol but this is for a grid system that can twist and bend. I want it to be scalable to have different sized spaces for a somewhat stylized LOD effect :-)