yuanming-hu / taichi_mpm

High-performance moving least squares material point method (MLS-MPM) solver. (ACM Transactions on Graphics, SIGGRAPH 2018)
MIT License
2.35k stars 315 forks source link

Explanation please: (p.x*inv_dx-Vec(0.5_f)).cast<int>(); #3

Closed Schizo closed 6 years ago

Schizo commented 6 years ago

Hi,

just a quick question, what is base_coord after the following line.

Vector2i base_coord = (p.x*inv_dx-Vec(0.5_f)).cast<int>();

Thanks a lot

yuanming-hu commented 6 years ago

Hi,that's the smallest (lower-left) grid node the particle will touch-Yuanming-------- Original Message --------Subject: [yuanming-hu/taichi_mpm] Explanation please: (p.xinv_dx-Vec(0.5_f)).cast(); (#3)From: Schizo To: yuanming-hu/taichi_mpm CC: Subscribed Hi, just a quick question, what is base_coord after the following line. Vector2i base_coord = (p.xinv_dx-Vec(0.5_f)).cast();

Thanks a lot

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread. {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/yuanming-hu/taichi_mpm","title":"yuanming-hu/taichi_mpm","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/yuanming-hu/taichi_mpm"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Explanation please: (p.xinv_dx-Vec(0.5_f)).cast\u003cint\u003e(); (#3)"}],"action":{"name":"View Issue","url":"https://github.com/yuanming-hu/taichi_mpm/issues/3"}}} [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/yuanming-hu/taichi_mpm/issues/3", "url": "https://github.com/yuanming-hu/taichi_mpm/issues/3", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } }, { "@type": "MessageCard", "@context": "http://schema.org/extensions", "hideOriginalBody": "false", "originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB", "title": "Explanation please: (p.xinv_dx-Vec(0.5_f)).cast\u003cint\u003e(); (#3)", "sections": [ { "text": "", "activityTitle": "Schizo", "activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png", "activitySubtitle": "@Schizo", "facts": [ { "name": "Repository: ", "value": "yuanming-hu/taichi_mpm" }, { "name": "Issue #: ", "value": 3 } ] } ], "potentialAction": [ { "name": "Add a comment", "@type": "ActionCard", "inputs": [ { "isMultiLine": true, "@type": "TextInput", "id": "IssueComment", "isRequired": false } ], "actions": [ { "name": "Comment", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"yuanming-hu/taichi_mpm\",\n\"issueId\": 3,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}" } ] }, { "name": "Close issue", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"yuanming-hu/taichi_mpm\",\n\"issueId\": 3\n}" }, { "targets": [ { "os": "default", "uri": "https://github.com/yuanming-hu/taichi_mpm/issues/3" } ], "@type": "OpenUri", "name": "View on GitHub" }, { "name": "Unsubscribe", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 372930224\n}" } ], "themeColor": "26292E" } ]

Schizo commented 6 years ago

Sorry, I think your message got screwed, I just wanted to know, what the .cast() exactly does. Is this a static/dynamic cast?

yuanming-hu commented 6 years ago

My original response: that's the smallest (lower-left) grid node the particle will touch. .cast means element-wise convert float to int in the vector, i.e. floor when the elements are positive.

Thanks.

Schizo commented 6 years ago

elementwise, that's what I was looking for. Thanks a lot.

yuanming-hu commented 6 years ago

sounds good!