用等式绘制平面

时间:2017-07-09 21:34:38

标签: r 3d

如何在R中用3d绘制这个平面(方程)? 也许它有点简单,但我真的不明白。

0,8x-0,4y + 0,2z = 0

planes3d或plot3d可能吗?

除此之外,我想添加一个if-function 所以我的小闪亮应用程序可以使用data.frame中的数据绘制playnes。

它应该是此代码的一部分:

install.packages("shiny")
install.packages("rgl")
install.packages("plotrix")

library(shiny)
library(rgl)
library(plotrix)

ui <- fluidPage(
    headerPanel("Block Theory 0.1"),
    sidebarPanel(
        numericInput(inputId = "strike", label = "Strike:", value = "", width = "80%", min = 0, max = 360),
        numericInput(inputId = "dip", label = "Dip:", value = "", width = "80%", min = 0, max = 90),
        actionButton(inputId = "add", label = "Add a plane"),
        actionButton(inputId = "plotbutton", label = "Update")
    ),
    mainPanel(  
        rglwidgetOutput(outputId = "plot")
    ),
    verbatimTextOutput(outputId = "log_planes")
)

server <- function(input, output) {
    data_planes <- data.frame()
    makeReactiveBinding("data_planes")  

    observe({
        input$add
        isolate({
            data_planes <<- rbind(data_planes, data.frame(input$strike, input$dip))
            data_planes <<- na.omit(data_planes)
        })
    })  

    output$plot <- renderRglwidget({
        input$plotbutton
        isolate({
            if (i < nrow(data_planes)) {
                phi <- 90 - data_planes[1,1]
                deta <- data_planes[1,2]

                a <- sin(phi)*cos(deta)
                b <- sin(phi)*sin(deta)
                c <- cos(phi)

                planes3d(a,b,c,d = 0)

                i <<- i + 1
            }
            rglwidget() 
        })
    })
    output$log_planes <- renderPrint({print(data_planes)})
}

shinyApp(ui = ui, server = server)

0 个答案:

没有答案