Help with creating A-Frame roof maths

I recently made a post about this but I didn’t have the actual code, just an idea but now I have the code that generates the interior from the A-Frame roof

I taked the polygon(idk why I named as this lol) function from the EgoMoose example on Github.

    local centerPoint = point1:Lerp(point2, 0.5)
    centerPoint = Vector3.new(
        centerPoint.X,
        point1.Y,
        centerPoint.Z
    )
    
    q:SetPrimaryPartCFrame(
        CFrame.new(centerPoint + Vector3.new(0, (size.Y/2) - 0.5, 0))
    )
    
    point1 = q:GetPrimaryPartCFrame():PointToWorldSpace(
        q:GetPrimaryPartCFrame():PointToObjectSpace(point1)
    )
    
    centerPoint = q:GetPrimaryPartCFrame():PointToWorldSpace(
        q:GetPrimaryPartCFrame():PointToObjectSpace(centerPoint)
    )
    
    point2 = q:GetPrimaryPartCFrame():PointToWorldSpace(
        q:GetPrimaryPartCFrame():PointToObjectSpace(point2)
    )
    
    polygon(
        point1 - Vector3.new(0.5, 0.5, (0.5 + 0.025)),
        Vector3.new(
            centerPoint.X,
            point2.Y - (size.Y / 2),
            point1.Z - (0.5 + 0.025)
        ),
        Vector3.new(
            point2.X + 0.5,
            point1.Y - 0.5,
            point1.Z - (0.5 + 0.025)
        ),
        q
    )
    
    polygon(
        Vector3.new(
            point1.X - 0.5,
            point1.Y - 0.5,
            point2.Z + (0.5 + 0.025)
        ),
        Vector3.new(
            centerPoint.X,
            point2.Y - (size.Y / 2),
            point2.Z + (0.5 + 0.025)
        ),
        Vector3.new(
            point2.X + 0.5,
            point1.Y - 0.5,
            point2.Z + (0.5 + 0.025)
        ),
        q
    )

I want to create the exterior part
ll

Based on the positions to create the triangle (to be relative to triangle angle)

1 Like

This is also the triangle in-live

Got the solution